#7541 closed (fixed)
newforms-admin: doesn't respect overridden querysets in formfields
| Reported by: | 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 , 17 years ago
| Keywords: | nfa-blocker added; nfa removed |
|---|---|
| milestone: | → 1.0 alpha |
| Owner: | changed from to |
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:3 by , 17 years ago
| Triage Stage: | Accepted → Fixed on a branch |
|---|
Kudos to Brosner, thanks a lot!
Note:
See TracTickets
for help on using tickets.
(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.