Hi, A question that's probably obvious but I can't quite see the best way to do it.
I've got a model, call it Template, with some fields colour1, colour2 etc. What I want is that if there's a no value for the colourN field then a default value is returned when the field is read. Aha I hear you say, just use class Template(models.Model): colour1 = models.CharField(default = "red") However, as far as I can tell this only fills in a default value when the object is first created. I've got two problems with that: 1) these are new fields on the model, and I've got a whole pile of existing records where these are going to be blank. Setting default="red" in the model doesn't seem to fix that. 2) I do want people to be able to set a colour in the admin, change their minds, set it to blank and have the original colour restored. Boiling it down, I want a way to make the colour1 field work like this: def _get_colour1(self): if self.value == '': return self.default_value else: return self.value I can't spot an obvious way to do this - what have I missed? Thanks, Malcolm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.