Show Menu

Django Basics Cheat Sheet by

Django basic project and app setup
development     python     web     framework     django

Start a Project

$ startproject tango_my_django

Add a static content folder (Javas­cri­pt/CSS)

$ mkdir -p tango_my_django/static/css
$ mkdir -p tango_my_django/static/js

STATIC_PATH = os.path.join(PROJECT_PATH,'static')
STATIC_URL = '/static/'

Add a Templates Folder

$ mkdir -p tango_my_django/templates/rango

TEMPLATE_PATH = os.path.join(PROJECT_PATH, 'templates')

Create a Template

<!DOCTYPE html>
{% load static %}


Start a App

$ tango_my_django/ startapp tango_my_django/rango

Add App to Project


INSTALLED_APPS = ( ..., ..., 'rango', )

Route from Project to App


# Include tango_my_django/rango/
urlpatterns = patterns('', url(r'^mainApp/', include('mainApp.urls')),)

Route from App to View


from django.conf.urls import url, patterns
from mainApp import views

urlpatterns = patterns('', url(r'^$', views.index, name='index'),)

Create a view


from django.conf.http import HttpResponse

def index(request):
    return HttpResponse("hello rango")

Use Template inside a View


from django.shortcuts import render_to_response
from django.template import RequestContext

def index(request):
    context = RequestContext(request)
    context_dict = {'boldmessage' : 'I come from context_dict'}
    return render_to_response('mainApp/index.html', context_dict, context)

Download the Django Basics Cheat Sheet

2 Pages

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

Like this cheat sheet? Check out our sponsors! is a collection of tools to make your writing better. More readable content means higher conversion rates and better reader engagement. Measure website and document readability, measure keyword density and more!

Click Here To Get Started!



No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Polymer.js Cheat Sheet
          Selenium WebDriver Cheat Sheet Cheat Sheet