On Wed, Nov 16, 2011 at 3:16 PM, Jaroslav Dobrek
<jaroslav.dob...@gmail.com> wrote:
> I forgot to say:
>
> (1) I deleted the database completely and created it again.
> (2) I ran manage.py syncdb
>
> However, with this code
>
>  def clean_date_of_birth(self):
>         date_of_birth = self.cleaned_data.get('date_of_birth')
>         if date_of_birth:
>             if date_of_birth.year < 1890:
>                 raise forms.ValidationError(u"It is very
> improbable...")
>         return date_of_birth
>
> I still get the database problem.
>
> Jaroslav
>

If you don't want to have to have that field in rows in the database,
then you need more than blank=True on the model field, you also need
null=True. The documentation for those two options explains why, blank
is purely for validation purposes in Django admin/modelforms, where as
null controls whether a field is allowed to be missing in the
database.

https://docs.djangoproject.com/en/1.3/ref/models/fields/#blank
https://docs.djangoproject.com/en/1.3/ref/models/fields/#null

The confusion comes about because charfields do not require null=True,
as empty or missing strings are stored as the empty string rather than
as a null string.

Cheers

Tom

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to