Re: limit_choices_to a value on a field in the same model

2010-03-14 Thread Brandon Taylor
Walt, you're a lifesaver! Many thanks for the great example. I only made a couple of minor tweeks: class AgencyForm(forms.ModelForm): class Meta: model = Agency def __init__(self, *args, **kwargs): super(AgencyForm, self).__init__(*args, **kwargs) if

Re: limit_choices_to a value on a field in the same model

2010-03-14 Thread Walt
Here is an idea of what your forms.py should contain: class AgencyForm(ModelForm): class Meta: model = Agency def __init__(self, *args, **kwargs): super(AgencyForm, self).__init__(*args, **kwargs) if self.instance.id: if self.instance.state_id:

limit_choices_to a value on a field in the same model

2010-03-13 Thread Brandon Taylor
Evening Everyone, I have a model "Agency" with "state" as a foreign key and "counties" as a many-to-many. County has a foreign key to "state" I would like to limit the County choices in Django admin to the state of the Agency being edited, but, I can't seem to find the right place to get an