-
-
Save vikaskyadav/fb146ac8e18da577a5d0749d51e97154 to your computer and use it in GitHub Desktop.
Django Commands Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use Python 3 for easy unicode | |
$ virtualenv -p python3 .env | |
$ source .env/bin/activate | |
$ pip install django | |
$ deactivate | |
# Start new django project and app | |
$ django-admin.py startproject mysite | |
$ ./manage.py migrate | |
$ ./manage.py createsuperuser | |
$ ./manage.py startapp myapp | |
# Run django | |
$ ./manage.py shell | |
$ ./manage.py runserver | |
# django migration | |
$ ./manage.py makemigrations myapp | |
$ ./manage.py sqlmigrate myapp 0001 | |
$ ./manage.py migrate | |
$ ./manage.py squashmigrations myapp 0004 | |
# django database backup & restore | |
$ ./manage.py dumpdata --indent 2 --exclude auth.permission --exclude contenttypes > db.json | |
$ ./manage.py loaddata db.json | |
# sqlite3 | |
$ sqlite3 db.sqlite3 | |
sqlite> .tables | |
# test | |
from django.test.utils import setup_test_environment | |
setup_test_environment() | |
$ python manage.py test myapp | |
# Distribution | |
$ python setup.py sdist | |
$ pip install django-package-0.1.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment