Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#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)

auto_populated_field_script.patch (2.5 KB ) - added by panta@… 16 years ago.
auto_populated_field_script patch for multiple slugs in a model

Download all attachments as: .zip

Change History (7)

comment:1 by Adrian Holovaty, 17 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 Jacob, 17 years ago

Resolution: fixed
Status: newclosed

(In [4034]) Fixed #2972: prepopulate_from now works with multiple slugs on the same field. Thanks, Archatas.

by panta@…, 16 years ago

auto_populated_field_script patch for multiple slugs in a model

comment:3 by panta@…, 16 years ago

Resolution: fixed
Status: closedreopened
Version: 0.95SVN

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 Pete Crosier, 16 years ago

Summary: [patch] Auto population doesn't work for multiple slugs on the same modelAuto population doesn't work for multiple slugs on the same model

comment:5 by Jacob, 16 years ago

Resolution: worksforme
Status: reopenedclosed

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.

in reply to:  5 comment:6 by anonymous, 16 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?

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