Hi Marc, 

  if I remember correctly (can't check now), the documentation clearly states 
that you should avoid using null=True on CharField unless you have a good 
reason. Your example is a textbook reason why is it recommended - having two 
distinct states for "empty string" (i.e. "blank" and "null") leads to 
inconsistencies and confusion.

  HTH

     Jirka

-----Original Message-----
From: Marc Aymerich <glicer...@gmail.com>
Sender: django-users@googlegroups.com
Date: Thu, 1 Mar 2012 22:43:19 
To: <django-users@googlegroups.com>
Reply-To: django-users@googlegroups.com
Subject: null field issue

I have a model with a filed like
    name = models.CharField(max_length=255, blank=True, null=True)

With Django admin I've created some instances of that model without
filling name field. Now I'm querying that model with name__isnull=True
and the filter doesn't return any single object!! acctually on the
database (postgresql) the name field is an empty string '' instead of
the expected NULL.

Why the admin fills name field with an empty string? Is this a normal
behaviour?

-- 
Marc

-- 
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.

-- 
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