On Saturday 08 July 2006 02:52, Malcolm Tredinnick wrote: > You cannot store NULL values via the admin interface. The reason for > this is that a web interface is poorly designed as far as being able to > differentiate between an empty string and a NULL. If the field is blank, > which one did you mean? Empty or NULL?
Well, if the field is blank and if I said that I'd like to store NULL values in the model definition, I guess I want to store NULL in the database, not empty strings. If that's not the case, I'm probably good for the pshrink. :) Anyway, I still can override the default save() method with something like that: def save(self): if self.bar == '': self.bar = None super(Foo, self).save() > So Django always makes it an > empty string for character-based fields. I still think that for CharFields with null=True, the admin interface should store values as NULL. If I prefer to store them as empty strings, I just have to say blank=True, leave null=False, and that would do it. To handle cases where mixed NULL and empty strings would have to be stored in the same db column, I think that it could be worth to add an 'empty_asnull' option in the CharField class. What do you think? My 0.02¤. :) -- Kilian CAVALOTTI Administrateur réseaux et systèmes UPMC / CNRS - LIP6 (C870) 8, rue du Capitaine Scott Tel. : 01 44 27 88 54 75015 Paris - France Fax. : 01 44 27 70 00 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---