anyone on this ? On Tue, Jul 13, 2010 at 2:44 PM, rahul jain <jainwolver...@gmail.com> wrote: > Could it be generic ?. I mean i don't want to specify self.naughty_field. > > How to do it for self.any_field ? > > RJ > > On Tue, Jun 29, 2010 at 9:29 AM, euan.godd...@googlemail.com > <euan.godd...@gmail.com> wrote: >> Django admin can't differentiate between empty string and None and >> picks empty string which makes sense in most cases. >> >> If you don't like the idea of empty string override the save method >> and coerce empty string to None before calling the super classes save, >> e.g. >> >> class YourModel(models.Model): >> ... >> >> def save(self, *args, **kwargs): >> if self.naughty_field == '': >> self.naughty_field = None >> super(YourModel, self).save(*args, **kwargs) >> >> Euan >> >> On Jun 29, 4:15 pm, rahul jain <jainwolver...@gmail.com> wrote: >>> Hi there ! >>> >>> One of my model fields attribute is set to null="true" to allow None >>> values. But if I use admin to save those model objects and leave it >>> blank, it saves blank value instead of None. >>> How to fix this ? >>> >>> And Blank value is not None. Blank is "" (empty) but None is NULL in >>> databases. >>> >>> -RJ >> >> -- >> 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. >> >> >
-- 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.