heywbj / django-rest-framework-recursive

Recursive Serialization for Django REST framework
ISC License
367 stars 39 forks source link

required is not propagated on children #9

Closed j-san closed 8 years ago

j-san commented 8 years ago

example:

class StuffSerializer(serializers.ModelSerializer):
  children = RecursiveField(many=True, required=False, allow_null=True)

works fine if I send:

{...}

but if I send children, children of children are required:

{
  "children": [
    {...},
    {...}
  ]
}

// response:
{
  "children":[
    {"children":["This field may not be null."]},
    {"children":["This field may not be null."]}
  ]
}

And finally works if I send empty children of children:

{
  "children": [
    {..., "children": []},
    {..., "children": []}
  ]
}
heywbj commented 8 years ago

https://github.com/heywbj/django-rest-framework-recursive/blob/master/tests/test_recursive.py#L102 https://github.com/heywbj/django-rest-framework-recursive/blob/master/tests/test_recursive.py#L16 https://travis-ci.org/heywbj/django-rest-framework-recursive/jobs/97511834

Seems to work fine. What version of django/django-rest-framework are you using?

closing for now. Reopen the ticket if you can't figure it out.

j-san commented 8 years ago

Django == 1.8 drf == 3.1.1 Upgraded and tested to drf 3.3 and it works like a charm ! Thank you for your help :)