Skip to content
Advertisement

Tag: django-rest-framework

Get current user in Model Serializer

Is it possible to get the current user in a model serializer? I’d like to do so without having to branch away from generics, as it’s an otherwise simple task that must be done. My model: My serializer: And my view: How can I get the model returned, with an additional field user such that my response looks like this:

OperationalError, no such column. Django

I am going through the Django REST framework tutorial found at http://www.django-rest-framework.org/ I am almost finished with it and just added authentication. Now I am getting : I have looked in several places on the web, not just StackOverflow for the solution, it seems like in general that the problem is with my database and need to delete it then

Django Rest Framework File Upload

I am using Django Rest Framework and AngularJs to upload a file. My view file looks like this: As the last line of post method should return all the data, I have several questions: how to check if there is anything in request.FILES? how to serialize file field? how should I use parser? Answer Use the FileUploadParser, it’s all in

Django REST Framework serializer field required=false

from the documentation: read_only Set this to True to ensure that the field is used when serializing a representation, but is not used when updating an instance during deserialization. Defaults to False required Normally an error will be raised if a field is not supplied during deserialization. Set to false if this field is not required to be present during

Advertisement