Commits

Ian Struble committed 89eadb6

Cleaned up sloppy and fragile empty value check in AutocompleteWidget.render().

  • Participants
  • Parent commits d16a8aa

Comments (0)

Files changed (2)

File django/contrib/admin/widgets.py

         return url
 
     def render(self, name, value, attrs=None, hattrs=None, initial_objects=u''):
-        if value is None or (type(value) != int and len(value) == 0):
+        if not value:
             value = ''
         hidden_id = 'id_hidden_%s' % name
         hidden_attrs = self.build_attrs(type='hidden', name=name, value=value, id=hidden_id)

File tests/regressiontests/admin_widgets/tests.py

             conditional_escape(w.render('test', album.pk, attrs={})),
             expected,
         )
+        self.assertEqual(
+            conditional_escape(w.render('test', long(album.pk), attrs={})),
+            expected,
+        )
 
 
 class MultipleAutocompleteWidgetTest(DjangoTestCase):