Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #14363 -- Fixed render method of ManyToManyRawIdWidget …

…to set attrs to an empty dict. Thanks, tyrion and dpn.

Backport from trunk (r13971).

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13975 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 36ce5d0b3a5af8bae8282590b2a510272953958e 1 parent 6d30b28
Jannis Leidel authored October 01, 2010
2  django/contrib/admin/widgets.py
@@ -164,6 +164,8 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
164 164
     in a <select multiple> box.
165 165
     """
166 166
     def render(self, name, value, attrs=None):
  167
+        if attrs is None:
  168
+            attrs = {}
167 169
         attrs['class'] = 'vManyToManyRawIdAdminField'
168 170
         if value:
169 171
             value = ','.join([force_unicode(v) for v in value])
2  tests/regressiontests/admin_widgets/models.py
@@ -133,6 +133,8 @@ class CarTire(models.Model):
133 133
 >>> w = ManyToManyRawIdWidget(rel)
134 134
 >>> print conditional_escape(w.render('test', [m1.pk, m2.pk], attrs={}))
135 135
 <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>
  136
+>>> print conditional_escape(w.render('test', [m1.pk]))
  137
+<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>
136 138
 >>> w._has_changed(None, None)
137 139
 False
138 140
 >>> w._has_changed([], None)

0 notes on commit 36ce5d0

Please sign in to comment.
Something went wrong with that request. Please try again.