33
28
The accepted answer works but is unnecessarily complicated. You can just change the ID field to not be readonly. E.g. something like this will do:
id = serializers.IntegerField(required=False)
- [Django]-How to implement a "back" link on Django Templates?
- [Django]-Django Manager Chaining
- [Django]-How to server HTTP/2 Protocol with django
2
You have set id
as a ReadOnlyField
. Thatβs why id
does not appear in validated data. Just remove this line:
id = serializers.ReadOnlyField()
- [Django]-What does this "-" in jinja2 template engine do?
- [Django]-Django template how to look up a dictionary value with a variable
- [Django]-Django :How to integrate Django Rest framework in an existing application?
- [Django]-Django: Error: You don't have permission to access that port
- [Django]-CharField with fixed length, how?
- [Django]-Django admin sort foreign key field list
Source:stackexchange.com