On Sat, Jul 27, 2013 at 5:56 PM, Ivan Voras <[email protected]> wrote:

> Thanks, everyone!
>
> While I'm here: is there a way to create additional db objects in the
> syncdb phase? Specifically, I'd like to create some database VIEWs as
> a means of avoding using raw queries in my code. Ideally, I would like
> a way of specifying my own SQL which creates a Model's database object
> (so I can do a CREATE VIEW instead of CREATE TABLE), or something like
> that.
>
> You have two options.

Firstly, you can use Django's ability to invoke raw SQL as part of the
syncdb process:

https://docs.djangoproject.com/en/1.5/howto/initial-data/#providing-initial-sql-data

Although the examples in that documentation describe using INSERT
statements, you can issue any SQL statement you want.

Secondly, you could use South.

http://south.aeracode.org

South is a migration framework for Django -- it allows you to manage
changes in database schema, but you can also include creation of additional
views, indexes, etc as part of that process.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to