Allow In-depth serialization by specifying depth to follow relationship
|Reported by:||Owned by:||nobody|
|Cc:||mattimustang@…, datavortex@…, django@…, tosters@…, Tom Christie, kmike84@…, hv@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
It would be nice to be able to specify whether to traverse relationships when calling serialize.
For example, say you had 2 models defined as:
class Reporter(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=30) email = models.EmailField() class Article(models.Model): headline = models.CharField(maxlength=100) pub_date = models.DateField() reporter = models.ForeignKey(Reporter)
If you serialize a queryset from the Article model, the result will only contain the primary keys of the related Reporter models. I think an additional argument specifying the maximum depth to traverse relationships (similar to select_related). So if you pass 1 as the depth in the above example, the result will contain the complete deserialization of the related Reporter objects as well.
Change History (34)
comment:1 Changed 9 years ago by
|Summary:||In-depth serialization → Allow In-depth serialization by specifying depth to follow relationship|
|Triage Stage:||Unreviewed → Design decision needed|