Opened 17 years ago
Closed 15 years ago
#9211 closed (duplicate)
Objects with newlines in representation break popup JavaScript in the admin
| Reported by: | jbronn | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.0 |
| Severity: | Keywords: | admin popup newline carriage | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When you have these models:
class Note(models.Model):
text = models.TextField()
def __unicode__(self):
return self.text
class Person(models.Model):
name = models.CharField(max_length=25)
note = models.ForeignKey(Note)
def __unicode__(self):
return self.name
And the following in admin.py:
from django.contrib import admin from models import Note, Person admin.site.register(Note) admin.site.register(Person)
When entering a Person model in the admin a new may Note created by clicking the plus icon next to the selection list. If the person entering the note presses return and puts newlines in the TextField, the dismissAddAnotherPopup JavaScript chokes on the Notes representation.
Attached is a patch that escapes carriage returns, however, I want some discussion on whether there needs to be any other escaping performed.
Attachments (1)
Change History (5)
by , 17 years ago
| Attachment: | admin_escape_popup_newlines.diff added |
|---|
comment:1 by , 17 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:4 by , 15 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Should this be done with
escapejs()instead? That would handle the cases you've identified and a few dozen others as well. At first glance, it looks like the right tool here, but I might be missing something.