Skip to content
Advertisement

Django Rest Framework File Upload

I am using Django Rest Framework and AngularJs to upload a file. My view file looks like this:

JavaScript

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?

Advertisement

Answer

Use the FileUploadParser, it’s all in the request. Use a put method instead, you’ll find an example in the docs :)

JavaScript
Advertisement