Fixed #14363 -- Fixed render method of ManyToManyRawIdWidget to set attrs to an empty dict. Thanks, tyrion and dpn.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13971 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2010-10-01 02:31:05 +00:00
parent 113b0bde66
commit 941e11e54d
2 changed files with 4 additions and 0 deletions

View File

@ -156,6 +156,8 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
in a <select multiple> box.
"""
def render(self, name, value, attrs=None):
if attrs is None:
attrs = {}
attrs['class'] = 'vManyToManyRawIdAdminField'
if value:
value = ','.join([force_unicode(v) for v in value])

View File

@ -133,6 +133,8 @@ HTML escaped.
>>> w = ManyToManyRawIdWidget(rel)
>>> print conditional_escape(w.render('test', [m1.pk, m2.pk], attrs={}))
<input type="text" name="test" value="1,2" class="vManyToManyRawIdAdminField" /><a href="../../../admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a>
>>> print conditional_escape(w.render('test', [m1.pk]))
<input type="text" name="test" value="1" class="vManyToManyRawIdAdminField" /><a href="../../../admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a>
>>> w._has_changed(None, None)
False
>>> w._has_changed([], None)