Start a real Django application
Category: /blog /djangoTags: django heroku
Basic commands
-
create a virtual environment first.
cd $HOME/sites virtualenv –system-site-packages $prj_name workon $prj_name cd $HOME/workspace/ django-admin startproject $prj_name ./manage.py startapp $app_name
-
create initial tables.
migrate
looks forINSTALLED_APPS
setting and create necessary tables../manage.py migrate
-
if you want to view the changes only before taking any migration action.
./manage.py makemigrations $modified_app_name
-
to make the actual changes to migration files.
./manage.py sqlmigrate $modified_app_name 0001
-
make all migrations to the database.
./manage.py migrate
-
use shell command.
./manage.py shell
如果你已经删除了某个table,
manage.py migrate ziputil zero # the django way
# if the table is deleted using other way
manage.py migrate ziputil zero --fake
manage.py migrate ziputil
Bash completion
Download shell script from Django source repo.
wget -O ~/bin/django_bash_completion.sh \
https://raw.github.com/django/django/master/extras/django_bash_completion
Add the following line to .bashrc
.
. $HOME/bin/django_bash_completion.sh