Accessing model subclass attributes with django tastypie -


I have a model that has been published

  class fu (models.model ): Name = model.carfield (max_long = 255) child_model = models.charfield (max_length = 255) square bar (foo): woots = models.ManyToManyField (Woot) class Woot (models.Model): color = models.CharField ( Max_length = 255)   

and some tastypie resources:

  class FooResource (ModelResource): class meta: queryset = Foo.objects.all () class BarResource (ModelResource): Square Meta: queryset = Foo.objects.all () Class WootResource (ModelResource): Class Meta: queryset = Woot.objects.all ()   

When access to FooResource , so I ideally change it to 'again' and bar-resorts instead, if child_model attribute == times

If I can not do this, then by any means I can sort any kind of woots (when the child_model attribute == bar) will be fine by me.

Try S:

  class FooResource (ModelResource): class Meta: queryset = Foo.objects.all () DEF Dehydrate (self, bundle): If bundle.data ['child_model'] == "bar": return json.loads (BarResource (.) Sender_list (request bundle). Content) Return Bundle    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -