Ticket #3982: coerce.diff
File coerce.diff, 782 bytes (added by , 18 years ago) |
---|
-
django/db/models/fields/__init__.py
140 140 cls._meta.add_field(self) 141 141 if self.choices: 142 142 setattr(cls, 'get_%s_display' % self.name, curry(cls._get_FIELD_display, field=self)) 143 if hasattr(self, 'coerce'): 144 dispatcher.connect(self._force_coercion, signal=signals.post_init, sender=cls) 143 145 146 def _force_coercion(self, sender, instance, signal, *args, **kwargs): 147 value = self.coerce(getattr(instance, self.attname)) 148 setattr(instance, self.attname, value) 149 144 150 def get_attname(self): 145 151 return self.name 146 152