Opened 16 years ago

Closed 16 years ago

Last modified 13 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: no UI/UX: no

Description

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 by Brian Rosner, 16 years ago

Keywords: nfa-blocker added; nfa removed
milestone: 1.0 alpha
Owner: changed from nobody to Brian Rosner
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by Brian Rosner, 16 years ago

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 by lukas@…, 16 years ago

Triage Stage: AcceptedFixed on a branch

Kudos to Brosner, thanks a lot!

comment:4 by Jacob, 13 years ago

milestone: 1.0 alpha

Milestone 1.0 alpha deleted

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