﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16226	[patch] prepopulated_fields only work with slug fields and break on non-char fields	Peter Kese	Peter Kese	"While analyzing ticket #15922, it became apparent that `prepopulate_from` field in Django admin unconditionally assumes that all prepopulated fields are of type `SlugField` and thus the `URLify` function in javascript is always called.

In addition it is assumed that each target field has a `max_length` attribute. However, only fields that inherit from a CharField have `max_length`. For all other field types, the javascript just fails.

Besides samples in #15922, here is another sample case in which any text in the `starting_price` field will be prepopulated in `price` field slugified:
{{{
# models.py

from django.db import models

class Book(models.Model):
    starting_price = models.CharField(max_length=100)
    price = models.CharField(max_length=100)

# admin.py

from django.contrib import admin
import models

class BookAdmin(admin.ModelAdmin):
    prepopulated_fields = {
        'price': ['starting_price'],
    }

admin.site.register(models.Book, BookAdmin)
}}}
"	Bug	closed	contrib.admin	dev	Normal	wontfix		peter.kese@…	Design decision needed	1	0	0	0	0	1
