How can I define a list field in django rest framework?

There is also the ListField in django rest framework, see http://www.django-rest-framework.org/api-guide/fields/#listfield

wtih the examples:

scores = serializers.ListField(
    child=serializers.IntegerField(min_value=0, max_value=100)
)

and (other notation):

class StringListField(serializers.ListField):
    child = serializers.CharField()

this seems simpler (maybe this class is added later than the accepted anwser, but seems good to add this option anyway)

By the way, it’s added since djang rest framework 3.0: http://www.django-rest-framework.org/topics/3.0-announcement/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)