Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#14193 closed (fixed)

prepopulated_fields should concatenate fields in given order

Reported by: bmihelac Owned by: bmihelac
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: 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

When generating slug from more than one field order of fields in list should be respected.

Currently, the order in which fields are rendered in admin form affects the slug creation.

In the following example, slug would look "first_name-last_name" and I would expect "last_name-first_name".

class Person(models.Model):
    first_name = models.CharField(_('First name'), max_length=80)
    last_name = models.CharField(_('Last name'), max_length=80)

class PersonAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ('last_name', 'first_name')}

To change the order, one can swap the order in Person model, but it would be more naturally if populate would respect order that is given with tuple.

If you agree, I can make a patch for this.

Attachments (1)

0001-Fix-for-14193-respect-given-order-when-creating-prep.patch (5.7 KB ) - added by bmihelac 14 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Luke Plant, 14 years ago

Triage Stage: UnreviewedAccepted

Agreed, patch gladly accepted! If this is just a javascript problem, you don't have to add tests since we don't have other tests for javascript functionality.

comment:2 by bmihelac, 14 years ago

Owner: changed from nobody to bmihelac
Status: newassigned

comment:3 by bmihelac, 14 years ago

Has patch: set

Because jQuery selected objects always return elements in document order I choosed to update prepopulate javascript function so it expects dependencies as array of field id's and not jQuery object.
Please let me know if you agree with this decission.

Patch is tested with regular admin forms, stacked and tabular formsets.

comment:4 by Matthias Kestenholz, 14 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Andrew Godwin, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [14122]) Fixed #14193: prepopulated_fields javascript now concatenates in correct order. Thanks to bmihelac for the patch.

comment:6 by Andrew Godwin, 14 years ago

(In [14123]) [1.2.X] Fixed #14193: prepopulated_fields javascript now concatenates in correct order. Thanks to bmihelac for the patch.

Backport of [14122] from trunk

comment:7 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

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