summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-07-14 13:14:28 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-07-14 13:14:28 +0000
commitf2a45f9b3883f974d2b48eb05612ff4e9b9b2946 (patch)
tree933e80c11d8e6b0ff8d5bf95a3306833e4ed6479
parent501448e3f2d9f66a559e5c64fb0d325c95cff82e (diff)
Fixed #4862 -- Fixed invalid Javascript creation in popup windows in admin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5694 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/templatetags/admin_list.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index 206a453383..0e96f28191 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -190,9 +190,11 @@ def items_for_result(cl, result):
table_tag = {True:'th', False:'td'}[first]
first = False
url = cl.url_for_result(result)
- result_id = smart_unicode(getattr(result, pk)) # conversion to string is needed in case of 23L (long ints)
+ # Convert the pk to something that can be used in Javascript.
+ # Problem cases are long ints (23L) and non-ASCII strings.
+ result_id = repr(force_unicode(getattr(result, pk)))[1:]
yield (u'<%s%s><a href="%s"%s>%s</a></%s>' % \
- (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr, table_tag))
+ (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), result_repr, table_tag))
else:
yield (u'<td%s>%s</td>' % (row_class, result_repr))