Ticket #5622: 5622.2.diff
File 5622.2.diff, 1.5 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/__init__.py
185 185 Used by the default implementations of ``get_db_prep_save``and 186 186 `get_db_prep_lookup``` 187 187 """ 188 return value 188 if self.empty_strings_allowed: 189 return value 190 else: 191 return value or None 189 192 190 193 def get_db_prep_save(self, value): 191 194 "Returns field's value prepared for saving into a database." -
tests/regressiontests/model_fields/models.py
39 39 class BigS(models.Model): 40 40 s = models.SlugField(max_length=255) 41 41 42 class IPModel(models.Model): 43 ip = models.IPAddressField(blank=True,null=True) 44 42 45 __test__ = {'API_TESTS':""" 43 46 # Create a couple of Places. 44 47 >>> f = Foo.objects.create(a='abc', d=decimal.Decimal("12.34")) … … 97 100 >>> bs = BigS.objects.get(pk=bs.pk) 98 101 >>> bs.s == 'slug' * 50 99 102 True 103 104 # Regression test for #5622 -- Ensure that None is returned for empty values in IPAddressField 105 >>> ip_model = IPModel.objects.create(ip="") 106 >>> ip_model = IPModel.objects.get(pk=ip_model.pk) 107 >>> ip_model.ip == None 108 True 100 109 """}