Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7541 closed (fixed)

newforms-admin: doesn't respect overridden querysets in formfields

Reported by: lukas@… Owned by: Brian Rosner
Component: contrib.admin Version: newforms-admin
Severity: Keywords: nfa-blocker
Cc: Triage Stage: Fixed on a branch
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Given this code:

class AdminPersonForm(forms.ModelForm):
    class Meta:
        model = Person
    def __init__(self, *args, **kwargs):
        super(AdminPersonForm, self).__init__(*args, **kwargs)
        self.fields["my_fk_field"].queryset = SomeModel.objects.filter(obj=self.instance)

class PersonAdmin(admin.ModelAdmin):
    form = AdminPersonForm

one would expect the dropdown list for my_fk_field in the admin to be limited to the assigned queryset. This is not the case in newforms-admin as of today - the resulting dropdown contains the unfiltered all()-queryset.

Brosner said in irc it might have something to do with RelatedFieldWidgetWrapper in django.contrib.admin.widgets.

Change History (4)

comment:1 Changed 8 years ago by Brian Rosner

Keywords: nfa-blocker added; nfa removed
milestone: 1.0 alpha
Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to Brian Rosner
Patch needs improvement: unset
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Brian Rosner

Resolution: fixed
Status: assignedclosed

(In [7771]) newforms-admin: Fixed #7541 -- RelatedFieldWidgetWrapper now wraps the widget and not the just the render function which caused some stale values. Thanks lukas and Doug Napoleone.

comment:3 Changed 8 years ago by lukas@…

Triage Stage: AcceptedFixed on a branch

Kudos to Brosner, thanks a lot!

comment:4 Changed 5 years ago by Jacob

milestone: 1.0 alpha

Milestone 1.0 alpha deleted

Note: See TracTickets for help on using tickets.
Back to Top