#9264 closed (fixed)
ModelAdmin: multipe items in prepopulated_fields breaks the auto-fillin
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | ||
Cc: | dgouldin@… | 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
In an admin.ModelAdmin class, this will pre-populate the 'slug' field on-the-fly in the admin:
prepopulated_fields = { 'slug': ('name',) }
However this will cause neither to be pre-populated on-the-fly:
prepopulated_fields = { 'slug': ('name',), 'another_slug': ('name2',) }
Attachments (1)
Change History (14)
comment:1 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Cc: | added |
---|
comment:3 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I have reviewed this too.
No, it's not reproducible. It does work perfectly well to have multiple slug fields like this:
class FooModelAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('name',), 'slug2': ('name2',) }
BUT! If you have multiple slug fields that expect to use the same fields you have a problem. For example:
class FooModelAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('name',), 'slug2': ('name',) }
What happens is effectively this:
... document.getElementById("id_name").onkeyup = function() { var e = document.getElementById("id_slug"); ... } document.getElementById("id_name").onkeyup = function() { var e = document.getElementById("id_slug2"); ... } ...
Which is fundamentally wrong since it overwrites the keyup event on the same element.
So attached is a patch to prepopulated_fields_js.html which use addEvent(my_dom_obj, 'keyup', function(){})
rather that my_dom_obj.onkeyup=function(){
}
by , 16 years ago
Attachment: | 9264.patch added |
---|
comment:5 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
If there's a patch to be tested, it doesn't sound like this is fixed?
comment:6 by , 16 years ago
This patch will conflict with the js patch in #9983, however. The patch there has been updated to include this fix.
comment:7 by , 16 years ago
Has patch: | set |
---|
comment:9 by , 15 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
This really should be updated to use jQuery now, but it's not a big deal. We can commit it and clean it up later if needed.
comment:10 by , 15 years ago
milestone: | 1.2 → 1.3 |
---|
I'm going to bump this off the 1.2 milestone, for a couple reasons:
- There are several tickets (this one, #9110, #9784 and #9983) all exposing cases where the event handling for
prepopulated_fields
falls over in specific edge cases, so the real solution is not to fix any of these individually but rather to makeprepopulate_from
more robust. - I suspect the admin-ui work will be coming up for discussion in the 1.3 timeframe, and that's a more solid place to talk about dealing with this.
comment:12 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
(In [12937]) Fixed #13068, #9264, #9983, #9784 - regression with pre-populated fields and javascript inlines, and related bugs.
Thanks to hejsan for the report, and to Sean Brant and Carl Meyer for the patch.
#13068 is a regression caused by the new javascript inline forms in the
admin. The others were existing javascript bugs with prepopulated fields.
Since the solution depends on jQuery and would likely be very hard to
backport without it, it will not be backported to 1.1.X.
I was not able to reproduce this. Can anybody else?