On Fri, 2007-03-23 at 22:15 +0100, Frank Tegtmeyer wrote:
[...]
> Questions:
> 
> 1. Why is the default value in the database not set to 0?

The 'default' attribute in Django is intentionally not passed through as
a database constraint when the table is constructed. This is partly
because there are problems with getting the quoting of said value
correct when constructing the table. There's one ticket in Trac that
keeps getting reopened (in spite of of our policy on reopening tickets)
that tries to fix this, but it isn't a complete solution, so we're not
including it. There are ways to work around this if you really want to,
though. You can put "ALTER TABLE" constructs in your initial SQL, for
example. There may be a nice solution to this that somebody can think of
and bring up on the django-developers list and it would probably be nice
to have (although I can also think of cases where it wouldn't be a good
idea), but it hasn't happened yet.

> 2. Why does the generic view not use the default value when inserting
>    blank values? Instead data with a wrong type (string) is used.

This is something we are trying to work out the ideal solution for, but
basically, the default value is overridden by whatever is supplied from
the form, on the grounds that the person filling in the form knew what
they were doing. If you want to fix that up, your form processing code
needs to change it back. There are good arguments for changing this so
that the default value overrides any empty string that is submitted, but
it's not a no-brainers change because there are also arguments for the
current behaviour. If I had to guess, I would say we'd change this
behaviour prior to 1.0 so that default values have some precedence, but
I haven't put a lot of thought into this yet, so there are some corner
cases that may influence that.

> 3. How can I work around the situation (suppress warnings?)?

In your form processing code, check for empty strings and update it with
the default value if you wish.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to