NOTE: A Django project may contain one or more apps
pip install Django will install Django
django-admin.py startproject <name_of_project> will create a new Django project with the following directory structure:
manage.py: the Django task runner scriptmanage.py is the same as django-admin.py plus:
See django-admin and manage.py
python manage.py startapp <name_of_app> will create a new Django app within this project with the following directory structure:
DB Tools:
manage.py sqlcreate: create database. Pipe this into your sql clientmanage.py sqldiff -a: check difference between models and db schemaMigrations:
manage.py makemigrations: created automatically from your model definitionsmanage.py showmigrationsmanage.py migrateUse manage.py graph_models to output DOT stream of database modeling.
You can specify default settings in settings.py:
GRAPH_MODELS = {
  'all_applications': True,
  'group_models': True,
}
Sometimes you’ll make changes so drastic in a new project that it’s better to redo your migrations:
manage.py migrate zero tomanage.py makemigrationDjango has an admin area (app) by default. Two Scoops believes its always easier to create a new admin then to override the defaults. The official Django documentation has information on overriding templates, adding new views, etc.
User via from django.contrib.auth.models import Usercreate_user(username, email=None, password=None, **extra_fields)url('^', include('django.contrib.auth.urls')) to your urlpatterns./manage.py createsuperuserTODO for implementing your User models:
INSTALLED_APPS
        MIDDLEWARE
        PASSWORD_HASHERS? (BCrypt)AUTH_PASSWORD_VALIDATORS?AbstractUserAbstractBaseUserAUTH_USER_MODEL
            user = models.OneToOne(settings.AUTH_USER_MODEL)url('^', include('django.contrib.auth.urls')) to urlpatternsauth_views and append each to urlpatterns@login_required on view defTwo Scoops of Django: Best Practices for Django 1.8. Daniel Roy Greenfeld & Audrey Roy Greenfeld. 2015-05-15.
Tango with Django. Leif Azzopardi & David Maxwell. 2016-10-04. Seems best for developers without prior MVC experience.
The Django admin site. Django Documentation.