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 self.instance
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:
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 insta
3 matches
Mail list logo