Start a real Django application

Category: /blog /django
Tags: django heroku

Basic commands

  1. 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

  2. create initial tables. migrate looks for INSTALLED_APPS setting and create necessary tables.

    ./manage.py migrate

  3. if you want to view the changes only before taking any migration action.

    ./manage.py makemigrations $modified_app_name

  4. to make the actual changes to migration files.

    ./manage.py sqlmigrate $modified_app_name 0001

  5. make all migrations to the database.

    ./manage.py migrate

  6. 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 ~/.django_bash_completion.sh \
https://raw.github.com/django/django/master/extras/django_bash_completion

Add the following line to .bashrc.

. $HOME/.django_bash_completion.sh

Resource

How to deploy to Heroku

Deploy Django Book

评论

Comments powered by Disqus

提示

  • 如果看不到评论部分, 请暂时关掉adblock in Firefox/Chrome
  • 本网站使用Javascript实现评论功能, 此处外链对提高您的网站PR没有帮助. (潜台词: 请不要灌水, 谢谢)