Ricky
Ricky

Reputation: 5377

How to get './manage.py syncdb' to create additional views or run custom SQL?

Is there a way to run some custom SQL statements after syncdb does it thing creating the tables for the models? Specifically, I would like to create some database views.

Upvotes: 6

Views: 2520

Answers (2)

Dave
Dave

Reputation: 3261

Note: As mentioned in the comments, this method is deprecated as of Django 1.7.

Or just create a file called sql/<modelname>.sql: http://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data

Upvotes: 4

Van Gale
Van Gale

Reputation: 43912

Yes, there are signals you can catch after a syncdb.

See management signals for docs.

This is how the contrib.auth permissions table is populated, as well as the contenttypes framework table.

Upvotes: 9

Related Questions