[Answer]-Django tastypie: how to retrieve a list of child objects and attach that list to the 'choices' field atrribute

1👍

Have a look at build_bundle() and full_dehydrate(). I haven’t tested this but maybe something like this would work.

from my_app.models import WORKLOAD_CHOICES

class BlueprintResource(ModelResource):

    def full_dehydrate(self, bundle, for_list=False):

         dic = dict([WORKLOAD_CHOICES])
         bundle.data['foo'] = self.build_bundle(data=dic)

         return super(BlueprintResource, self).full_dehydrate(bundle, for_list)

Leave a comment