#2972 closed defect (worksforme)
Auto population doesn't work for multiple slugs on the same model
Reported by: | Archatas <aidas.bendoraitis at gmail> | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If there is a model with more than one SlugField, then the javascript for automatic slug population is generated only for the last slug field of the model in the contributed administration.
The problem is simple and fixable in minutes.
The template tag auto_populated_field_script in django/contrib/admin/templatetags/admin_modify.py overwrites the previously collected javascript within every new iteration:
def auto_populated_field_script(auto_pop_fields, change = False): for field in auto_pop_fields: t = [] ... return ''.join(t)
What has to be changed is that the t list has to be defined before iteration start:
def auto_populated_field_script(auto_pop_fields, change = False): t = [] for field in auto_pop_fields: ... return ''.join(t)
Attachments (1)
Change History (7)
comment:1 by , 18 years ago
Summary: | Auto population doesn't work for multiple slugs on the same model → [patch] Auto population doesn't work for multiple slugs on the same model |
---|
comment:2 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
by , 17 years ago
Attachment: | auto_populated_field_script.patch added |
---|
auto_populated_field_script patch for multiple slugs in a model
comment:3 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | 0.95 → SVN |
In my case (r6373, konqueror on linux) it doesn't work.
I've attached a patch that solves the problem (tested both with konqueror and Firefox).
Cheers,
Marco
comment:4 by , 17 years ago
Summary: | [patch] Auto population doesn't work for multiple slugs on the same model → Auto population doesn't work for multiple slugs on the same model |
---|
follow-up: 6 comment:5 by , 17 years ago
Resolution: | → worksforme |
---|---|
Status: | reopened → closed |
I can't reproduce this, but it worksforme in Gecko/WebKit/IE, so I'm going to assume if there's a bug it's with Konqueror.
comment:6 by , 17 years ago
Replying to jacob:
I can't reproduce this, but it worksforme in Gecko/WebKit/IE, so I'm going to assume if there's a bug it's with Konqueror.
I am no js expert, and I can't say if it's a bug with konqueror or django, but the patch is super-simple, and many users use konqueror, so why not simply integrate the patch and make everyone happy?
(In [4034]) Fixed #2972: prepopulate_from now works with multiple slugs on the same field. Thanks, Archatas.