Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

The `.create()` method does not support writable nested fields by default. Write an explicit `.create()` method for serializer `room_api.serializers.roomSerializer`, or set `read_only=True` on nested serializer fields.

class CoreInformation(generics.ListCreateAPIView):
    queryset = models.CoreInformation.objects.all()
    serializer_class = CustomCoreInfoSerializer

    def create(self, request, *args, **kwargs):
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        instance = self.perform_create(serializer)
        serializer = self.get_serializer(instance=instance)
        return Response(serializer.data, status=status.HTTP_201_CREATED)

    def perform_create(self, serializer):
        return serializer.create(validated_data=serializer.validated_data)
Comment

PREVIOUS NEXT
Code Example
Python :: open text with utf-8 
Python :: python foresch 
Python :: sql alchemy engine all tables 
Python :: np load csv 
Python :: Find faculty of a number python 
Python :: python list remove spaces 
Python :: highlight max value in table pandas dataframe 
Python :: get href scrapy xpath 
Python :: how to add up a list in python 
Python :: python enumerate start at 1 
Python :: compute mad python 
Python :: python enumerate() function 
Python :: python tkinter set minimum window size 
Python :: django static url 
Python :: amazon response 503 python 
Python :: python 1 to 01 
Python :: column contains substring python 
Python :: python df select first x columns 
Python :: how to check if all characters in string are same python 
Python :: pyspark case when 
Python :: isinstance float or int 
Python :: one hot encoding numpy 
Python :: legend of colorbar python 
Python :: global keyword python 
Python :: array as an input in python 
Python :: python open a+ 
Python :: python dataframe shape 
Python :: df concat 
Python :: sys.executable 
Python :: join two dictionaries python 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =