0👍
✅
Just add the use_in='list'
to the subcategories in Category
class CategoryResource(ModelResource):
subcategories = fields.ToManyField(SubcategoryResource, 'subcategory_set', 'subcategories', full=True, use_in='list')
class Meta:
queryset = Category.objects.all()
1👍
Depending on the level of detail you’d like included when listing you can try setting full_list=False
on the categories relationship or using full_list
and full_detail
on the subcategories to alter the output.
http://django-tastypie.readthedocs.org/en/latest/fields.html#tastypie.fields.RelatedField.full_list
- [Answer]-Django: store calculations results on database readings
- [Answer]-How can I get fixed output from my django database
- [Answer]-How to save JSON from Vk.com API response to MongoDB?
- [Answer]-Django postres methods for external Database
- [Answer]-Django registration [Errno 10013] error
Source:stackexchange.com