Oh, sorry for the confusion, and thanks for the explaination. I thought that Django raised an IntegrityError in this case, and when it didn't happen I figured it was a bug.
I will make a recommendation (observation). To provide a blank value a a model and have it validate with full_clean, you have to specify blank=True. I would suggest that to maintain integrity between your applications logic and the database, Django should raise an IntegrityError, if blank=False. On Jan 2, 6:53 pm, Russell Keith-Magee <russ...@keith-magee.com> wrote: > On Mon, Jan 3, 2011 at 7:46 AM, Yo-Yo Ma <baxterstock...@gmail.com> wrote: > > I apologize ahead of time, if this bug is rather a user error. > > > If you have a model: > > > class Foo(Model): > > spam= CharField(max_length=30) > > xyz= CharField(max_length=30) > > > def __unicode__(self): > > return self.xyz > > > and you use it in the shell like this: > > >>>> Foo.objects.create(xyz="Hello") > > <Foo: Hello> > > > No IntegrityError was raised, even though ``spam`` is a required field. > > Yes, 'spam' is a required field. And if you investigate a little > closer, you'll see that it has a value -- the empty string. > > You'll note that the following also works, and is entirely consistent > with get_or_create(): > > >>> obj = Foo(xyz='Hello') > >>> obj.save() > > For reasons of historical significance, the default value for all > fields (CharField or otherwise) is "", unless: > * a default is provided by the user, or > * You've overridden get_default, or > * You're using Oracle (which has it's own special difficulties with "" vs > None) > > Yours, > Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.