I'd like PartnerRegistration's default_provider field to be filtered in PartnerRegistrationInline, like how Partner's default_provider field is filtered in PartnerAdmin.
When I try the code below, I get a DoesNotExist exception in: self.fields['default_provider'].queryset = self.instance.partner.providers raise self.field.rel.to.DoesNotExist What am I doing wrong? class Partner(Model): id = UUIDField(primary_key=True) providers = ManyToManyField('Provider', related_name='provider_partners', blank=True, null=True) default_provider = ForeignKey('Provider', null=True, blank=True, help_text='The calling service used to make calls through by default when using this partner') class PartnerForm(forms.ModelForm): """ Filter and only show what belongs to this partner.""" def __init__(self, *args, **kwargs): super(PartnerForm, self).__init__(*args,**kwargs) self.fields['default_provider'].queryset = self.instance.providers class PartnerRegistration(Model): id = UUIDField(primary_key=True) partner = ForeignKey('Partner',unique=True) default_provider = ForeignKey('Provider',verbose_name='default calling service', help_text='User this calling service when response doesn\'t specify one.') class PartnerRegistrationForm(forms.ModelForm): """ Filter and only show what belongs to this partner.""" def __init__(self, *args, **kwargs): super(PartnerRegistrationForm, self).__init__(*args,**kwargs) self.fields['default_provider'].queryset = self.instance.partner.providers class PartnerRegistrationInline(StackedInline): model = PartnerRegistration form = PartnerRegistrationForm class PartnerAdmin(ModelAdmin): form = PartnerForm inlines = [ PartnerRegistrationInline, ] -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.