Author: mtredinnick
Date: 2007-07-14 08:14:28 -0500 (Sat, 14 Jul 2007)
New Revision: 5694

Modified:
   django/trunk/django/contrib/admin/templatetags/admin_list.py
Log:
Fixed #4862 -- Fixed invalid Javascript creation in popup windows in admin.


Modified: django/trunk/django/contrib/admin/templatetags/admin_list.py
===================================================================
--- django/trunk/django/contrib/admin/templatetags/admin_list.py        
2007-07-14 12:48:24 UTC (rev 5693)
+++ django/trunk/django/contrib/admin/templatetags/admin_list.py        
2007-07-14 13:14:28 UTC (rev 5694)
@@ -190,9 +190,11 @@
             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))
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to