On Fri, 2006-07-07 at 17:17 +0530, Kenneth Gonsalves wrote:
> 
> On 07-Jul-06, at 4:08 PM, Kilian CAVALOTTI wrote:
> 
> > I created a model with a CharField which has to be NULL in the  
> > database. So I
> > gave it blank=True, null=True and unique=True options. I have to  
> > allow NULL
> > values in the database, as well as blank values in admin, but in  
> > the same
> > time, I'd like to be sure that non NULL values are unique.
> 
> i dont think any sane database would allow null values in a unique  
> column - or should

Be serious; it is completely spec compliant and with good reason. OK,
there is a school of thought that says you shouldn't allow NULLs at all
in databases, but they are not invited to the cool parties and NULLs are
permitted in SQL.

Imagine a column that shows seating number assignments for a list of
people. NULL means no ticket number assigned, otherwise it should be
unique (two people in one seat will not be universally popular). Or
hotel room bookings via a reference to the room table: a foreign key can
be NULL (customer exists but no room assigned yet), but if it is
assigned, it should be unique.

Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to