#16226: Admin prepopulated_fields only work with slug fields and break on 
non-char
fields
------------------------+-------------------------------
 Reporter:  peter_kese  |          Owner:  peter_kese
     Type:  Bug         |         Status:  new
Milestone:              |      Component:  contrib.admin
  Version:  SVN         |       Severity:  Normal
 Keywords:              |   Triage Stage:  Unreviewed
Has patch:  0           |  Easy pickings:  0
    UI/UX:  0           |
------------------------+-------------------------------
 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)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16226>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to