| 13 | |
| 14 | ''Edit: I realize I could have made the code simpler (see below), but that sample code is from my project where I have several range fields on my model so I loop through a list of field names to test for `None`. For clarity, the workaround is as simple as:'' |
| 15 | {{{ |
| 16 | class RangeTest(models.Model): |
| 17 | ... |
| 18 | def save(self, *args, **kwargs): |
| 19 | if self.age_range == None: |
| 20 | self.age_range = self._meta.get_field('age_range').range_type() |
| 21 | |
| 22 | super(RangeTest, self).save(*args, **kwargs) |
| 23 | |
| 24 | }}} |
| 25 | ''Apologies for adding confusion.'' |