On Wed, Jan 7, 2009 at 12:48 PM, Jeff Anderson <jeffe...@programmerq.net>wrote:

> Karen Tracey wrote:
> > On Wed, Jan 7, 2009 at 10:51 AM, Jeff Anderson <jeffe...@programmerq.net
> >wrote:
> >
> >
> >> varikin wrote:
> >>
> >>> I agree with this. I use null=False, blank=True for some ImageFields
> >>> and integers.
> >>>
> >> I'm interested in how a blank integer looks in a MySQL database. Can you
> >> provide an example
> > I believe the further description a bit later in the email covered this:
> >
> > In the case of an integer, I use it for order of the images. So if a
> number
> >
> >> is given for an image, it is used, otherwise auto assign the order
> number.
> >>
> >
> >
> > That is, blank is not actually stored in the DB but rather the lack of a
> > user-provided value triggers creation of an auto-assigned value.
> >
> But that is code that could/should belong in the form/validation code.


Could: probably, should: maybe, required to be: no.


> The models define how things are to be setup and stored in the database
> backend.
>

By that reasoning it sounds like blank should not be a model field
parameter, since it only controls what is accepted in forms for the model,
not what is stored in the database.


>
> A blank value in a webpage does not translate to a blank value in the
> database, so blank=True is incorrect in this case, as an auto-assigned
> value isn't actually blank, because a non-blank value will be stored in
> the database.
>

blank simply controls whether the form field is required.  It doesn't say
anything about what's stored in the database, that's what null is for.
They're decoupled, which allows for setting blank=True,null=False and
substituting a non-blank auto-generated value at some point after form
validation but before saving the model.  It may not be an approach you
prefer, but that does not make it incorrect.

Karen

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