This may seem like a silly question, but I really feel that the Django-Rest-Framework does not explain very well how this works. Too much black magic that confuses setup instructions (in my opinion).
For example, he says that I can override the creation or update in my serializer. Therefore, when I look at the message, I can send data to a serializer that has a declared update method.
class MySerializer(serializers.ModelSerializer): class Meta: model = MyModel def update(self, instance, validated_data):
Is an update called only when the model already exists, and we just update some of its data? Or does it cause you to create when you create a new one?
if I have to add this method to this class,
def create(self, validated_data): return MyObject.objects.create(**validated_data)
Is this specifically the method that needs to be called to add a new object? and your ability to override should be placed in a serializer, but if not declared, is this the default method with called parameters?
source share