1. Simon Meers
  2. django-countries

Commits

Chris Beaven  committed 5887851

Fix a bug with len(obj.countries) which was never actually working

  • Participants
  • Parent commits a26b80d
  • Branches default

Comments (0)

Files changed (2)

File django_countries/fields.py

View file
  • Ignore whitespace
         return bool(self.code)
 
     def __len__(self):
-        return self.code.size
+        return len(unicode(self))
     
     @property
     def name(self):

File django_countries/tests/__init__.py

View file
  • Ignore whitespace
 
         person = Person.objects.get(pk=person.pk)
         self.assertEqual(person.country, '')
+
+    def test_len(self):
+        person = self.create_person()
+        self.assertEqual(len(person.country), 2)
+
+        person = self.create_person(country=None)
+        self.assertEqual(len(person.country), 0)