Django

Code

Changeset 5694

Show
Ignore:
Timestamp:
07/14/07 08:14:28 (1 year ago)
Author:
mtredinnick
Message:

Fixed #4862 -- Fixed invalid Javascript creation in popup windows in admin.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/templatetags/admin_list.py

    r5609 r5694  
    191191            first = False 
    192192            url = cl.url_for_result(result) 
    193             result_id = smart_unicode(getattr(result, pk)) # conversion to string is needed in case of 23L (long ints) 
     193            # Convert the pk to something that can be used in Javascript. 
     194            # Problem cases are long ints (23L) and non-ASCII strings. 
     195            result_id = repr(force_unicode(getattr(result, pk)))[1:] 
    194196            yield (u'<%s%s><a href="%s"%s>%s</a></%s>' % \ 
    195                 (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr, table_tag)) 
     197                (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), result_repr, table_tag)) 
    196198        else: 
    197199            yield (u'<td%s>%s</td>' % (row_class, result_repr))