Skip to content

Instantly share code, notes, and snippets.

@rooklift
Last active February 28, 2016 21:51
Show Gist options
  • Save rooklift/44a20c87602732442105 to your computer and use it in GitHub Desktop.
Save rooklift/44a20c87602732442105 to your computer and use it in GitHub Desktop.
Notes on starting a Django 1.9 project

Initialisation...

  • django-admin startproject site
  • python manage.py startapp appname

Views and URLs...

  • Edit appname/views.py
  • Edit appname/urls.py
  • Edit site/urls.py

Migrate...

  • python manage.py migrate

Register the app...

  • Edit site/settings.py INSTALLED_APPS to include 'appname.apps.AppnameConfig'

Models...

  • Edit appname/models.py
  • python manage.py makemigrations appname
  • python manage.py migrate

Enable admin activity...

  • python manage.py createsuperuser
  • Edit appname/admin.py

Templates...

  • Create these in appname/templates/appname/

User authentication...

  • mkdir site/templates/registration
  • Create templates login.html and logged_out.html
  • Edit site/urls.py to include:
    url(r'^', include('django.contrib.auth.urls')),
  • Edit site/settings.py to include:
    'DIRS': ['site/templates']  # inside the TEMPLATES dictionary
    
    LOGIN_URL = '/login/'
    LOGIN_REDIRECT_URL = '/'
  • Guard views with @login_required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment