While working with Django you use a lot of commands. I decided to create a list of commands for myself to make my development a little faster.
Quick links to tutorials:
- 1 – Working with models
- 2 – Creating admin panel
- 3 – Creating views and using templates
- 4 – Creating forms
- 5 – Testing
- 6 – Customizing apps look and feel
- Creating reusable apps
My project folder is this: ~/Documents/common-app-server/app_server
My project name is: tokens
Creating virtual environment:
$ virtualenv env
Activating virtual environment:
$ source env/bin/activate
Installing Django on virtual environment:
$ pip install Django
Django version:
$ python -c "import django; print(django.get_version())"
Starting a project:
$ django-admin.py startproject tutorial
Creating Django application:
(env)~/Documents/common-app-server/app_server: $ ./manage.py startapp multiverse
Syncing database for the first time:
python manage.py syncdb
Creating migrations:
$ ./manage.py makemigrations tokens
Looking at migrations:
$ ./manage.py sqlmigrate tokens 0001
Starting migrations:
$ ./manage.py migrate
Entering sqlite mode:
(env)~/Documents/common-app-server/app_server: $ ./manage.py dbshell
Recreating database:
1. Delete migrations folder
2. Use this command to clear database:
$ ./manage.py sqlclear tokens| ./manage.py dbshell
3. Create and run migrations
Running a local server:
$ ./manage.py runserver
Creating admin user:
$ ./manage.py createsuperuser
App view:
http://localhost:8000/tokens/
Admin view:
http://localhost:8000/admin/
Installing DjangoRestFramework:
$pip install djangorestframework
