Code

Opened 4 years ago

Closed 4 years ago

#13386 closed (wontfix)

Change name of ```ModelAdmin.prepopulated_fields``` to ```prepopulated_slug_fields``` to better reflect the actual purpose

Reported by: shanx Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The ModelAdmin.prepopulated_fields documentation now states:

When set, the given fields will use a bit of JavaScript to populate from the fields assigned. The main use for this functionality is to automatically generate the value for SlugField fields from one or more other fields. The generated value is produced by concatenating the values of the source fields, and then by transforming that result into a valid slug (e.g. substituting dashes for spaces).

See: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated_fields

This option is not a solution for using javascript in general to prepopulate fields in the admin, but is specifically designed for use with SlugField and autopopulating this type of field. Because of this specific use I propose to rename the option in a future version of Django to better clarify the intended use of this option. A more logical naming would be: prepopulated_slug_fields

So instead of:

class ArticleAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("title",)}

One would use:

class ArticleAdmin(admin.ModelAdmin):
    prepopulated_slug_fields = {"slug": ("title",)}

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Changing a field name like this would be a huge backwards incompatibility, and I'm not convinced that changing the name will add clarity.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.