On Fri, 2009-02-13 at 14:42 -0800, Chris Lieb wrote: > I am new to Django and am trying to write a model to interact with an > existing database. One of the fields in the database has a default > value. To compensate for this, I added default=0 to the Field > declaration. When I went to generate the DDL for the schema to make > sure that I had done everything correctly, I noticed that none of the > fields that I had set default for had DEFAULT 0 as part of their > definition. Is default only used in the admin application? I am > using > the sqlite3 backend.
Not only in the admin interface, no. It's used whenever you create a new instance and do not otherwise provide a value for that field. However, that is not the same as enforcing the default at the database level. Often, it wouldn't matter if defaults on models did translate to database-level defaults, but sometimes it does: particularly in the case of legacy databases where the Django-created data might well have different business requirements than data inserted by other, external processes. That's a little bit of an historical feature, but sometimes it's useful. 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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---

