#16226: [patch] 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 Resolution: | Keywords: Triage Stage: Unreviewed | Has patch: 1 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 1 | --------------------------------------+-------------------------------
Comment (by peter_kese): I just uploaded a small update to the patch, that solves for the `default` value handling in `max_length` javascript. Now, instead of {{{ maxLength: {{ field.field.field.max_length|default_if_none:"50" }} }}} I chose to rewrite that as {{{ maxLength: {{ field.field.field.max_length|default:'null' }} }}} Rationale: In the new code, `maxLength` is only used for `URLify`ing Slug fields and can be ignored (set to `null` or anything else) for any other field type.\\ According to documentation, `max_length` is required on any `CharField` (thus including `SlugField`). In addition, if `max_length` is set to `None` (or omitted) when defining a `SlugField`, the `SlugField`'s `__init__()` code will set the value to 50 - see [[/browser/django/trunk/django/db/models/fields/__init__.py#L1048]].\\ It is thus safe to assume that `max_length` will be set to a proper value for each `SlugField` instance and we thus don't need to do a special case in the javascript generation template.\\ As said, in all other cases `max_length` can be safely be ignored as the `URLify` doesn't even get called. -- Ticket URL: <https://code.djangoproject.com/ticket/16226#comment:3> 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.