def populate(self, product_id): # We can dynamically set choices for a form field: # Seen at: http://my.opera.com/jacob7908/blog/2009/06/19/ # django-choicefield-queryset (Chinese) # Is this documented elsewhere? query = {'product_id': product_id} self.fields['build'].queryset = Build.list_active(query)
def populate(self, product_id=None): # We can dynamically set choices for a form field: # Seen at: http://my.opera.com/jacob7908/blog/2009/06/19/ # django-choicefield-queryset (Chinese) # Is this documented elsewhere? if product_id: self.fields['product_version'].queryset = Version.objects.filter( product__pk=product_id) self.fields['build'].queryset = Build.objects.filter( product__pk=product_id) else: self.fields['product_version'].queryset = Version.objects.all() self.fields['build'].queryset = Build.list_active()
def populate(self, product_id): query = {'product_id': product_id} self.fields['build'].queryset = Build.list_active(query)