Opened 15 years ago

Closed 12 years ago

#11732 closed New feature (wontfix)

ModelAdmin.get_changelist_form should use ModelAdmin.form

Reported by: Eduardo de Oliveira Padoan Owned by: nobody
Component: contrib.admin Version: 1.1
Severity: Normal Keywords:
Cc: andy@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When you create a ModelForm to associate with a ModelAdmin, using the 'form' option, this form will not be used on the list_editable form. When I define a .clean() method, I'd like the validation to work both on the changeform and on the changelist.

A quick fix:

     def get_changelist_form(self, request, **kwargs):
         defaults = {
+            "form": self.form,
            "formfield_callback": curry(self.formfield_for_dbfield,
                                              request=request),
         }
         defaults.update(kwargs)
         return modelform_factory(self.model, **defaults)

Change History (10)

comment:1 by Eduardo de Oliveira Padoan, 15 years ago

milestone: 1.2

comment:2 by Luke Plant, 15 years ago

Triage Stage: UnreviewedDesign decision needed

That's a really bad idea, and would cause lots of breakages, because many people will be assuming that the Form they have created will be used only for the change form, and not the change list. We need a new attribute like 'changelist_form', if anything.

comment:3 by James Bennett, 15 years ago

milestone: 1.2

1.2 is feature-frozen, moving this feature request off the milestone.

comment:4 by Andy Baker, 15 years ago

Cc: andy@… added

comment:5 by Yeago, 14 years ago

I agree with lukeplant and yet with raw_id_fields, here we are creating an admin option which affects both.

comment:6 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:7 by Julien Phalip, 13 years ago

Easy pickings: unset
UI/UX: unset

See related issue in #11651.

comment:8 by anonymous, 12 years ago

Any updates on this ?

comment:9 by pwbdecker@…, 12 years ago

Presently to add validation to the change list form I have to override get_changelist_form to return my custom form. I would also like to see the option to be able to use the admin options form.

comment:10 by Jacob, 12 years ago

Resolution: wontfix
Status: newclosed

I'm with Luke: this isn't something we should change; the downsides outweigh the upsides.

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