Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to allow only for create field in serializer

class TodoModifySerializer(ModelSerializer):

    def to_internal_value(self, data):
        data = super(TodoModifySerializer, self).to_internal_value(data)
        if self.instance:
            # update
            for x in self.create_only_fields:
                data.pop(x)
        return data

    class Meta:
        model = Todo
        fields = ('id', 'category', 'title', 'content')
        create_only_fields = ('title',)
Comment

PREVIOUS NEXT
Code Example
Python :: python color print 
Python :: generate all combinatinosrs of a list pyton 
Python :: update ubuntu to python 3.85 
Python :: link in embed discord.py 
Python :: python icon on task bar 
Python :: Check if the url is reachable or not in Python 
Python :: log loss python 
Python :: python dictionary to list 
Python :: to see version matplotlib 
Python :: python how to find circumference of a circle 
Python :: compose functions python 
Python :: list to dict python with same values 
Python :: rock paper scissors python 
Python :: python datetime add 
Python :: python tuple to dict 
Python :: combine df columns python 
Python :: hash() python 
Python :: pandas df sample 
Python :: create endpoint in python 
Python :: numpy mean 
Python :: np.where 
Python :: django annotate vs aggregate 
Python :: local ip 
Python :: how to shuffle array in python 
Python :: split at first occurrence python 
Python :: number of spaes pythopn 
Python :: count occurrences of character in string python using dictionary 
Python :: add readme cmd 
Python :: python open google 
Python :: How to check palindrom in python 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =