Opened 15 years ago

Closed 14 years ago

Last modified 13 years ago

#11639 closed New feature (fixed)

Can't remove prepopulated fields from fieldset in ModelAdmin

Reported by: leanmeandonothingmachine Owned by: nobody
Component: contrib.admin Version: 1.3-beta
Severity: Normal Keywords: sprintnov13
Cc: Ben Spaulding Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'd like to propose that when the prepopulated fields argument that is passed to the AdminForm helper in BaseModelAdmin is generated by a method that takes the request object. That would give you ability to use the get_fieldsets overide to filter out prepopulated fields and then use this new override to alter the prepopulated fields to match what you did in get_fieldsets. See attached patch for my implementation.

Attachments (1)

pre_populated.diff (9.5 KB ) - added by leanmeandonothingmachine 14 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 by leanmeandonothingmachine, 15 years ago

Sorry that should be in ModelAdmin not BaseModelAdmin

comment:2 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:3 by leanmeandonothingmachine, 15 years ago

I updated the patch so it applies against trunk.

comment:4 by leanmeandonothingmachine, 14 years ago

milestone: 1.3
Version: 1.11.2

Updated the patch again. If there is anything wrong with this that is holding it up please lmk, i'd be happy to improve it.

comment:5 by steph, 14 years ago

Keywords: sprintnov13 added

comment:6 by Ben Spaulding, 14 years ago

Cc: Ben Spaulding added

comment:7 by Julien Phalip, 14 years ago

milestone: 1.31.4
Needs documentation: set
Needs tests: set

That's a useful feature, but unfortunately it is too late for 1.3.

by leanmeandonothingmachine, 14 years ago

Attachment: pre_populated.diff added

comment:8 by leanmeandonothingmachine, 14 years ago

milestone: 1.41.3
Version: 1.21.3-beta

I updated the patch to include tests and documentation. I also added inline support based on the way get_readonly_fields works. Can this be considered for 1.3? If it really is too late then change it back to 1.4, it would be nice though to have this get some attention.

comment:9 by leanmeandonothingmachine, 14 years ago

Needs documentation: unset
Needs tests: unset

comment:10 by Julien Phalip, 14 years ago

Triage Stage: AcceptedReady for checkin

This is a good patch, thanks for your great work. There's no guarantee that it can make it in 1.3 as this is essentially a new feature and we're now in beta stage. So we'll see ;)

comment:11 by Russell Keith-Magee, 14 years ago

milestone: 1.31.4

Agreed that this looks like a good idea, but it's definitely a new feature, not a bug fix, so it can't be added to 1.3 at this point.

comment:12 by leanmeandonothingmachine, 14 years ago

Ok, on the other hand it could be considered a fix for the bug in #13618

comment:13 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:14 by defaultwombat, 14 years ago

Easy pickings: unset

This is definitly a fix for #13618 too.

Additionally it solves a problem when trying to manually fix the #13618 issue by changeing the prepopulated_fields e.g. in the change_view.
As this is a dictionary shared over all instances of the Adminmodel, after altering it you lost the prepopulating feature until server refresh.

comment:15 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: newclosed

In [16069]:

Fixed #11639, #13618 -- Added get_prepopulated_fields method to ModelAdmin and InlineModelAdmin to be able to handle prepopulated fields on a case-by-case basis. Thanks, leanmeandonothingmachine.

comment:16 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

comment:17 by hcarvalhoalves@…, 13 years ago

UI/UX: unset

Any reason why this ticket didn't entered 1.3.1? It's still set for 1.3-beta. I would like to see this checked in for 1.3.2, let me know if I can help with tests or documentation. It's pretty annoying to have the get_fieldsets hook available but see it fail because of prepopulated_fields , and then rewrite almost half of the ModelAdmin to fix it.

in reply to:  17 comment:18 by Ramiro Morales, 13 years ago

Replying to hcarvalhoalves@…:

Any reason why this ticket didn't entered 1.3.1?

It's because bug fixes like this are no longer backported to the stable branch - it will not be in the next 1.3.X release. See https://docs.djangoproject.com/en/dev/internals/release-process/#supported-versions -- We changed our backporting policy for the maintenance period post 1.3.

It's still set for 1.3-beta

I was reported as present in 1.3 beta (Version field of this ticket) but it was targetted to be fixed in 1.4 (Milestone field, since then removed from our Trac installation)

I would like to see this checked in for 1.3.2, let me know if I can help with tests or documentation. It's pretty annoying to have the get_fieldsets hook available but see it fail because of prepopulated_fields , and then rewrite almost half of the ModelAdmin to fix it.

You can always port the changes committed to fix this ticket (or a subset of them) to a local copy of the 1.3.X branch and use that.

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