Clear a FileField using PATCH

21 views
Skip to first unread message

Rober Morales-Chaparro

unread,
Dec 13, 2016, 3:49:02 PM12/13/16
to Django REST framework
Hi all,

I just realized that Django Admin allows clear a FileField sending a '<fieldname>-clear' parameter to 'on'. I am trying to reproduce this feature, or something equivalent, using DRF.

I read that using an empty string in the param '<fieldname>' can do the job, but I did not get to clear the field using a PATCH request. I cannot use PUT, since there are lots of fields and I do not know exactly the value for everything, so I cannot do a PUT that overwrite that unknown values.

Which is the canonical way of clear a FileField using a partial update in DRF?

Thanks,






Juan Antonio Alvarez

unread,
Dec 15, 2016, 3:35:11 PM12/15/16
to django-res...@googlegroups.com
On Tue, Dec 13, 2016 at 5:49 PM, Rober Morales-Chaparro <rober....@gmail.com> wrote:

Which is the canonical way of clear a FileField using a partial update in DRF?

Don't know if canonical, but sending {"fieldname": null} should do the trick.

Juan

ro...@ontropos.com

unread,
Jan 11, 2017, 5:49:13 AM1/11/17
to Django REST framework
Thanks!!!
Reply all
Reply to author
Forward
0 new messages