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: brosner
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 brosner

  • Keywords nfa-blocker added; nfa removed
  • milestone set to 1.0 alpha
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to brosner
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 8 years ago by brosner

  • Resolution set to fixed
  • Status changed from assigned to closed

(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 changed from Accepted to Fixed on a branch

Kudos to Brosner, thanks a lot!

comment:4 Changed 5 years ago by jacob

  • milestone 1.0 alpha deleted

Milestone 1.0 alpha deleted

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