Skip to content

Commit

Permalink
add nested genericrelation serializers to default_fields in django 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Dec 23, 2013
1 parent 20de96b commit 4de1d91
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ def add_labels(name, field, qs):
)
fields[accessor] = cls(context=self.context)

for vf in self.opts.model._meta.virtual_fields:
if getattr(vf, 'serialize', False) and vf.name not in fields:
cls = self.router.get_serializer_for_model(
vf.rel.to, self.opts.depth - 1
)
fields[vf.name] = cls(context=self.context)

return fields

def get_nested_field(self, model_field):
Expand Down

0 comments on commit 4de1d91

Please sign in to comment.