#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)
Change History (8)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 14 years ago
Attachment: | 0001-Fix-for-14193-respect-given-order-when-creating-prep.patch added |
---|
comment:3 by , 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 , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.