Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #14363 -- Fixed render method of ManyToManyRawIdWidget to set a…

…ttrs to an empty dict. Thanks, tyrion and dpn.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13971 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 941e11e54d175f4ffc769852e5dd376ec1ba5239 1 parent 113b0bd
Jannis Leidel jezdez authored
2  django/contrib/admin/widgets.py
View
@@ -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])
2  tests/regressiontests/admin_widgets/models.py
View
@@ -133,6 +133,8 @@ class CarTire(models.Model):
>>> 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)
Please sign in to comment.
Something went wrong with that request. Please try again.