On Wed, 2007-08-15 at 13:37 -0700, hiddenhippo wrote:
> Recently new to the Django world and having a slight issue with
> default values as defined within my django model.  take the following,
> which has been stripped, for clarity purposes.
> 
> class test(models.Model):
>     language_code = models.CharField(default="en-gb",maxlength=10)
> 
> 
> when i run the sycndb command everything appears fine, however no
> default value is defined within the database; below details the sql as
> it appears in the 'sql pane' within postgress (latest version)
> 
> CREATE TABLE subscriber
> (
>   id serial NOT NULL,
>   language_code character varying(10) NOT NULL,
> )
> 
> Can anybody please help?  or am i simply getting this wrong, and that
> django will take care of passing the default value...e.g. the database
> validation check is actually performed by django rather than at the
> database level.  Typically when I've create software there's usually
> two levels of validation; the one sitting within the software I write,
> but should bogus values make it through, then the database is there
> performing additional checks. 

Often this is appropriate, but sometimes it isn't. That is one reason
Django doesn't enforce this behaviour. What is a good default value when
Django is updating the database (based on web input, etc), might not be
the only possible default or the best constraint when other apps are
updating it -- particularly if you are using legacy data from somewhere.

So Django does not put the default constraint on the database column.

There is a Google Summer of Code project going on at the moment for
Django which is designed to allow for adding database constraints. You
might want to have a look at that (search for django-check-constraints
on Google projects hosting).

Regards,
Malcolm

-- 
Why be difficult when, with a little bit of effort, you could be
impossible. 
http://www.pointy-stick.com/blog/


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