On Sep 11, 2006, at 11:25 AM, Gary Wilson wrote: > The name field does not have blank=True or null=True set, but yet I am > able to create a new Name object using no parameters (because > CharFields and children are defaluting to empty string). Is this the > intended behavior?
Yes, from the documentation: http://www.djangoproject.com/documentation/model_api/#null "Note that empty string values will always get stored as empty strings, not as NULL -- so use null=True for non-string fields such as integers, booleans and dates. Avoid using null on string-based fields such as CharField and Text Field unless you have an excellent reason. If a string-based field has null=True, that means it has two possible values for "no data":NULL, and the empty string. In most cases, it's redundant to have two possible values for "no data"; Django convention is to use the empty string, not NULL." > gabor wrote: > >> yes, (unfortunately) it is. >> >> the models do not validate their input. >> >> you will have to use a manipulator (Name.AddManipulator) to validate >> your input (and then save the object). >> >> making the models validation-aware is planned, but not done yet. >> > > But I am not talking about validating my input here. I just don't > want > input to be inserted for me. For example, non-specified IntegerField > attributes don't defalut to zero. So why then do non-specified > CharField attributes default to empty string? The reason that integers without values insert as null is because their empty_strings_allowed value is False. Most non-string fields in Django have this set to False, text fields have it set to True, in order to assert the behavior described in the documentation. To override this behavior, you need to set a default value. Note that when gabor mentioned validation, he was talking about your comment about not setting blank=True. Blank=True/False is a framework constraint, null=True/False is a database constraint. Don --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers -~----------~----~----~----~------~----~------~--~---