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['product_version'].queryset = Version.objects.filter(product__id = product_id) self.fields['build'].queryset = TestBuild.list_active(query)
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['product_version'].queryset = Version.objects.filter( product__id=product_id) self.fields['build'].queryset = TestBuild.list_active(query)
def __init__(self, author, plan, *args, **kwargs): super(NewReviewForm, self).__init__(*args, **kwargs) self.plan = plan self.author = author query = {'product_id': self.plan.product_id} self.fields['build'].queryset = TestBuild.list_active(query)
def __init__(self, author, plan, *args, **kwargs): super(NewReviewForm, self).__init__(*args, **kwargs) self.plan = plan self.author = author query = {'product_id': self.plan.product_id} self.fields['build'].queryset = TestBuild.list_active(query)