James Crasta avatar James Crasta committed 184bbea

Don't need to explicitly convert USStateField, it converts itself as a select field.

Comments (0)

Files changed (3)

tests/ext_django/tests.py

         self.assertEqual(form.a.validate(form), True)
         self.assertEqual(form.b.data, None)
         self.assertEqual(form.b.validate(form), False)
-        form = self.F(DummyPostData(b=[2]))
+        form = self.F(DummyPostData(a=['__None'], b=[2]))
+        assert form.a.data is None
         self.assertEqual(form.b.data.pk, 2)
         self.assertEqual(form.b.validate(form), True)
 
+    def test_get_label_alt(self):
+        class TestForm(Form):
+            a = QuerySetSelectField(queryset=self.queryset, widget=lazy_select, get_label=lambda x: x.name.upper())
+        form = TestForm()
+        self.assertEqual(form.a(), ('N:1:USERS', 'N:2:ADMINS'))
 
 class ModelSelectFieldTest(DjangoTestCase):
     fixtures = ['ext_django.json']

wtforms/ext/django/fields.py

         self.blank_text = blank_text
         self._set_data(None)
         if queryset is not None:
-            self.queryset = queryset.all() # Make sure the queryset is fresh
+            self.queryset = queryset.all()  # Make sure the queryset is fresh
 
         if get_label is None:
             self.get_label = lambda x: x

wtforms/ext/django/orm.py

         kwargs['validators'].append(validators.url())
         return f.TextField(**kwargs)
 
-    def conv_USStateField(self, model, field, kwargs):
-        try:
-            from django.contrib.localflavor.us.us_states import STATE_CHOICES
-        except ImportError:
-            STATE_CHOICES = []
-
-        return f.SelectField(choices=STATE_CHOICES, **kwargs)
-
     def conv_NullBooleanField(self, model, field, kwargs):
         def coerce_nullbool(value):
             d = {'None': None, None: None, 'True': True, 'False': False}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.