#7903 closed (fixed)
Javascript errors with prepopulated_fields in admin
Reported by: | ElliottM | Owned by: | Jacob |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | admin javascript prepopulated fields prepopulated_fields | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When I set the prepopulated_fields property in my ModelAdmin, I get the following Javascript error (as reported by firebug):
None is not defined onkeyup() (line 149) if (!e._changed) { e.value = URL...ntById("id_description").value, None); } http://127.0.0.1/admin/network/path/add/
My model:
class Path(models.Model): circuit_id= models.CharField(max_length=16, db_index=True, unique=True) description=models.CharField(max_length=64) comments= models.TextField(blank=True) speed= models.CharField(max_length=8, blank=True) in_use= models.BooleanField(db_index=True)
The ModelAdmin for that model:
class PathAdmin(admin.ModelAdmin): list_display=('circuit_id','description','comments','speed','in_use') list_filter=('in_use',) search_fields=('circuit_id',) prepopulated_fields= {'comments':('description',)}
The error results in the comments field not being prepopulated.
This happens both on my Mac 10.5 running Firefox 2.0.0.11 and my Kubuntu Hardy computer running Firefox 3.0
Attachments (2)
Change History (17)
comment:1 by , 16 years ago
Summary: | Javascript errors with preopulated_fields → Javascript errors with preopulated_fields in admin |
---|
comment:2 by , 16 years ago
Keywords: | admin javascript prepopulated fields prepopulated_fields added |
---|
comment:3 by , 16 years ago
comment:5 by , 16 years ago
I was just trying it out with a pre-existing model to see how it worked. I didn't even intend to use it like that, just wanted to see it in action.
by , 16 years ago
Attachment: | 7903.patch added |
---|
comment:6 by , 16 years ago
It probably does not make much sense to support this, but here is a patch which just uses the default SlugField length.
comment:7 by , 16 years ago
Has patch: | set |
---|
comment:8 by , 16 years ago
milestone: | → 1.0 |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:9 by , 16 years ago
Summary: | Javascript errors with preopulated_fields in admin → Javascript errors with prepopulated_fields in admin |
---|
comment:10 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Design decision needed → Ready for checkin |
comment:11 by , 16 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
This isn't ready for checkin yet, since the patch no longer applies. There's been some refactoring in that template since the patch was created and the relevant code has been moved elsewhere. The idea's good and it can go in, but can somebody regenerate the patch against the new home of that fragment of code (and then bump it back to "ready for checkin")?
by , 16 years ago
comment:12 by , 16 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:13 by , 16 years ago
Patch needs improvement: | unset |
---|
comment:14 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I am beginning to wonder why you are using a
TextField
for the field to prepopulate. What is the behavior you want with that? It appears the Javascript is working right the
textarea
element. I also wonder if this something that should be allowed or not. I tend to lean to preventing the behavior in validation of the ModelAdmin.