Django-rest-framework: Lists are not currently supported in HTML input.

Created on 13 Oct 2017  路  10Comments  路  Source: encode/django-rest-framework

I get this error when make serializers for a ManytoMany field:
image
Please help me fix this.

Most helpful comment

This feature could be a nice enhancement for future releases.

All 10 comments

Nested serializers don't work with the browsable API.
Use the json content type instead.

Same issue comes when using django postgres ArrayField. Is there any solution for it? Even changing the field to comma separated string using drf ListField does not solve this.

https://stackoverflow.com/questions/48330135/django-rest-framework-serialize-arrayfield-as-string/48344897

Hi @krdeepak - the underlying issue is that lists are not well represented by HTML form inputs. I would recommend switching over to the JSON input instead.

As to the SO article, I think if you were to inherit CharField, this might work. e.g.,

class StringArrayField(CharField, ListField):
    ...

@krdeepak Did you find any real solution to this?

No, I just use raw json input when needed.

@krdeepak for quick response.

Why does it work in admin?

This feature could be a nice enhancement for future releases.

No, I just use raw json input when needed.

when i want to upload image at that time raw json could not work is there any idea about it

@lalitvasoya You can set the ListField parameter required = False and then make a PUT request to update the same object.

Was this page helpful?
0 / 5 - 0 ratings