Permalink
Browse files

Automatically Call syncdb

To make sure that the database structure is properly created, we
want to call ``manage.py syncdb`` automatically each time we push
our code. On the first push, this will create the Django tables;
later, it will create new tables that might be required by new
models you will define.

To make that happen, we create a ``postinstall`` script. It is
called automatically at the end of each push operation.

..

A few remarks:

* this is a shell script (hence the ``#!/bin/sh`` shebang at the
  beginning), but you can also use a Python script if you like;
* by default, ``syncdb`` will interactively prompt you to create
  a Django superuser in the database, but we cannot interact with
  the terminal during the push process, so we disable this thanks
  to ``--noinput``.

If you push the code at this point, hitting the ``/admin`` URL
will display the login form, but we don't have a valid user yet,
and the login form won't have the usual Django CSS since we didn't
take care about the static assets yet.
  • Loading branch information...
1 parent 616bb70 commit 00b9155b4f7cf72c35cc47e930195bb24ca734db @jpetazzo committed Sep 1, 2011
Showing with 2 additions and 0 deletions.
  1. +2 −0 postinstall
View
2 postinstall
@@ -0,0 +1,2 @@
+#!/bin/sh
+python hellodjango/manage.py syncdb --noinput

0 comments on commit 00b9155

Please sign in to comment.