Re: CharFields and children defaulting to emtpy string

2006-09-23 Thread Gary Wilson
Malcolm Tredinnick wrote: > Think about how the data is entered: through a web form (the admin > interface, or a custom form). Now, how do you differentiate between an > explicit empty string and a "no data entered and so it should be NULL" > field? With web entry, you can't, so Django chooses to

Re: CharFields and children defaulting to emtpy string

2006-09-17 Thread Gary Wilson
David and I have both introduced use cases where defaulting to empty string have caused problems. What are some use cases where an empty string would need to be used instead of NULL? IMO, all FormFields should act the same and default to NULL. If you want the database field to default to someth

Re: CharFields and children defaulting to emtpy string

2006-09-17 Thread DavidA
gabor wrote: > > assuming that you want to differentiate between: > > - the user did not fill in the data > - the user's input was "" > > wouldn't it be better to represent this in html as a checkbox+an input > field? > > and by default have the checkbox unselected, and the input-field disabled.

Re: CharFields and children defaulting to emtpy string

2006-09-16 Thread Malcolm Tredinnick
Hi Gabor, OK, ignore my post -- you were offering an alternative to David's idea, not proposing a universal change. /me backs sheepishly away from the keyboard and goes to get some coffee and wake up. Malcolm --~--~-~--~~~---~--~~ You received this message bec

Re: CharFields and children defaulting to emtpy string

2006-09-16 Thread Malcolm Tredinnick
On Sat, 2006-09-16 at 16:28 +0200, gabor wrote: > DavidA wrote: > > > > Malcolm Tredinnick wrote: > >> When I first started using Django, this drove me nuts. > > > > I had the same reaction, but also understand there isn't a great way to > > handle it. In Microsoft's SQL Enterprise Manager, you

Re: CharFields and children defaulting to emtpy string

2006-09-16 Thread gabor
DavidA wrote: > > Malcolm Tredinnick wrote: >> When I first started using Django, this drove me nuts. > > I had the same reaction, but also understand there isn't a great way to > handle it. In Microsoft's SQL Enterprise Manager, you can enter Ctrl-0 > in a field and it will set that field to N

Re: CharFields and children defaulting to emtpy string

2006-09-16 Thread DavidA
Malcolm Tredinnick wrote: > When I first started using Django, this drove me nuts. I had the same reaction, but also understand there isn't a great way to handle it. In Microsoft's SQL Enterprise Manager, you can enter Ctrl-0 in a field and it will set that field to NULL. I'm thinking about doi

Re: CharFields and children defaulting to emtpy string

2006-09-15 Thread Malcolm Tredinnick
Hey Gary, On Thu, 2006-09-14 at 02:09 +, Gary Wilson wrote: [...] > Ok, after some trial and error, I see that if you have null=True on a > CharField, it will use NULL instead of empty string. This is what I > needed because in my model I have a field that I want to be optional > but unique.

Re: CharFields and children defaulting to emtpy string

2006-09-13 Thread Don Arbow
On Sep 13, 2006, at 7:09 PM, Gary Wilson wrote: > > Out of curiosity, any one know for what reason using empty strings for > CharFields is the Django convention? Technically, isn't an empty > string still data? Isn't it a bit confusing that some fields get > default values and others do not? Ex

Re: CharFields and children defaulting to emtpy string

2006-09-13 Thread Marc D.M.
On Thu, 2006-09-14 at 02:09 +, Gary Wilson wrote: > Out of curiosity, any one know for what reason using empty strings for > CharFields is the Django convention? Technically, isn't an empty > string still data? Isn't it a bit confusing that some fields get > default values and others do not

Re: CharFields and children defaulting to emtpy string

2006-09-13 Thread Gary Wilson
Don Arbow wrote: > 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

Re: CharFields and children defaulting to emtpy string

2006-09-13 Thread Don Arbow
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 docu

Re: CharFields and children defaulting to emtpy string

2006-09-13 Thread Gary Wilson
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

Re: CharFields and children defaulting to emtpy string

2006-09-11 Thread gabor
Gary Wilson wrote: > using the example model: > > class Name(models.Model): > name = models.CharField(maxlength=100) > > when making a new Name object... a=Name() a.save() a > a.name > '' > > The name field does not have blank=True or null=True set, but yet I am > able