Warn when DateTimeField has blank=True but not null=True?

181 views
Skip to first unread message

Simon Willison

unread,
Aug 1, 2008, 4:16:28 AM8/1/08
to Django developers
Got some feedback the other day that someone using Django had got a
bit stuck for a while because they had a DateTimeField with blank=True
but not null=True. Would it make sense to throw a warning here? I'm
not even sure if different databases agree on what to store for a not
null blank date - I'm sure MySQL does something like 0000-00-00
00:00:00.

Cheers,

Simon

David Cramer

unread,
Aug 1, 2008, 7:17:55 AM8/1/08
to Django developers
In MYSQL you're completely screwed with those kind of DateField's in
most applications :)

Is there any particular reason null and blank aren't more tied
together? I would consider null=True defining blank=True, and in some
situations (and in good design for most things) vice versa.
Considering Django can't handle situations where a ForeignKey is
blank=True, but not nullable, so it default's to 0, it makes sense for
the ORM/Model API.

Martin

unread,
Aug 1, 2008, 7:43:50 AM8/1/08
to Django developers
It is not always the case that blank == null, for instance blank=True
on a CharField is ''.

Cheers,
Martin

Jacob Kaplan-Moss

unread,
Aug 1, 2008, 9:39:51 AM8/1/08
to django-d...@googlegroups.com
On Fri, Aug 1, 2008 at 3:16 AM, Simon Willison <si...@simonwillison.net> wrote:
> Got some feedback the other day that someone using Django had got a
> bit stuck for a while because they had a DateTimeField with blank=True
> but not null=True. Would it make sense to throw a warning here?

Yeah, I think so -- I've done this one myself by accident and it
causes very weird errors.

Jacob

Reply all
Reply to author
Forward
0 new messages