Django

Code

Ticket #7541 (closed: fixed)

Opened 2 months ago

Last modified 2 months ago

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

Reported by: lukas@einfachkaffee.de Assigned to: brosner
Milestone: 1.0 alpha Component: Admin interface
Version: newforms-admin Keywords: nfa-blocker
Cc: Triage Stage: Fixed on a branch
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.

Attachments

Change History

06/25/08 17:05:01 changed by brosner

  • status changed from new to assigned.
  • needs_better_patch changed.
  • needs_tests changed.
  • owner changed from nobody to brosner.
  • milestone set to 1.0 alpha.
  • keywords changed from nfa to nfa-blocker.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.

06/26/08 11:53:53 changed by brosner

  • status changed from assigned to closed.
  • resolution set to fixed.

(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.

06/26/08 18:05:12 changed by lukas@einfachkaffee.de

  • stage changed from Accepted to Fixed on a branch.

Kudos to Brosner, thanks a lot!


Add/Change #7541 (newforms-admin: doesn't respect overridden querysets in formfields)




Change Properties
Action