1👍
From DRF docs
If you want to implement a read-write relational field, you must also
implement the .to_internal_value(self, data) method.
So, you want to implement a read-write(POST/GET) field, so you need to implement .to_internal_value
method in your serializer.
1👍
You need to use nested serializers. The error is saying that there is no firstname filed on employee, which there isn’t. You need a serializer for both the Employee and UserData.
- [Answered ]-How to rate limit Celery tasks by task name?
- [Answered ]-Saving an image into user model
- [Answered ]-Can't send an email in Django 1.9
- [Answered ]-Django Admin – Disable Update For FK Fields
- [Answered ]-Django serve multiple domains with a single instance
0👍
I recently faced the same issue where I overwrote the to_representation
and create
method for the serializer.
In my case I forgot to add serializer.save()
in my viewset. The issue got resolved after adding it.
The cause of the error was when I called the serializer in the viewset it passed the body of the POST request as OrderedDict
to the obj in to_representation
method.
- [Answered ]-An alternative to cache_choices in django 1.8.1 to get rid of RemovedDjango1.9 cache_choices deprecation warning in forms
- [Answered ]-How to send latitude and longitude to django server using AJAX
- [Answered ]-Json recognised as String
- [Answered ]-Sentry-youtrack plugin: PicklingError: Can't pickle <type 'generator'>: attribute lookup __builtin__.generator failed
- [Answered ]-How to make two foreign keys to same model unique together?