#4174 closed (fixed)
[newforms-admin] prepopulated_fields results in javascript error (None is not defined)
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | newforms-admin |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I get this in Firefox 2:
Error: None is not defined Source File: http://localhost:8080/admin/page/section/add/ Line: 142
The javascript source is as follows:
<script type="text/javascript"> document.getElementById("id_slug").onchange = function() { this._changed = true; }; document.getElementById("id_title").onkeyup = function() { var e = document.getElementById("id_slug"); if (!e._changed) { e.value = URLify(document.getElementById("id_title").value, None); } } </script>
-Forest
Attachments (1)
Change History (13)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Version: | other branch → newforms branch |
comment:2 by , 18 years ago
Summary: | prepopulated_fields results in javascript error (newforms-admin) → [newforms-admin] prepopulated_fields results in javascript error (None is not defined) |
---|
comment:3 by , 18 years ago
Version: | newforms branch → newforms-admin |
---|
comment:4 by , 18 years ago
comment:5 by , 18 years ago
I stand corrected. My comments above should really be disregraded. I looked at this a little more in depth and it turns out this is a problem with the SlugField field implmentation. It subclasses Field and doesn't have a formfield method which Field's formfield method does not push over maxlength. If you subclass SlugField with CharField the problem is solved.
comment:7 by , 17 years ago
I believe this has been fixed as of r5926 in newforms-admin. Russell can you comment on this? If so, this ticket can be closed.
comment:11 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Doh! Sorry, I fixed this earlier tonight, completely forgot to look at the discussion here, and came to the same conclusions. That would have saved a few minutes of my life :) Fixed in [6056]
I came across this problem as well. I spent a little bit of time looking through the source to find the root of this problem.
In django/contrib/admin/templates/admin/change_form.html the line that causes the problem is (line 87 as of r5499):
The call to
{{ field.field.field.max_length }}
results in None. This is due to maxlength from the model not being push through to the formfield created by the model Field class. This may also be be field independent, but since pre_populated uses CharFields, it would be more specific to that.I guess the real question is, should maxlength be pushed over to the form field? I would it should, but perhaps some people will confuse that with an enforcement of that number in the actual form field. I don't know. ;) If it is as simple to move it over, I'd be up for writing a patch to fix that.