Show Menu
Cheatography

Djaneiro

Snippets for Django templates

autoescape
{% autoescape %} {% autoescape %}
block
{% block %} {% endblock %}
comment
{% comment %} {% endcomment %}
csrf
{% csrf_token %}
cycle
{% cycle %}
debug
{% debug %}
ext
{% extends "­" %}
extends
{% extends "­" %}
filter
{% filter %} {% endfilter %}
firstof
{% firstof %}
for
{% for in %} {% endfor %}
fore
{% for in %} {% empty %} {% endfor %}
if
{% if %} {% endif %}
ifchanged
{% ifchanged %} {% endifc­hanged %}
ife
{% if %} {% else %} {% endif %}
ifelse
{% if %} {% else %} {% endif %}
ifeq
{% ifequal %} {% endifequal %}
ifequal
{% ifequal %} {% endifequal %}
ifnotequal
{% ifnotequal %} {% endifn­otequal %}
inc
{% include %}
include
{% include %}
load
{% load %}
now
{% now "­" %}
regroup
{% regroup by as %}
spaceless
{% spaceless %} {% endspa­celess %}
ssi
{% ssi %}
static
{% static %}
templa­tetag
{% templa­tetag %}
url
{% url %}
verbatim
{% verbatim %} {% endver­batim %}
widthratio
{% widthratio %}
with
{% with as %} {% endwith %}
trans
{% trans %}
blocktrans
{% blocktrans with as %} {% endblo­cktrans %}

Non-of­ficial snippets for templates

super
{{ block.s­uper }}
extrahead
{% block extrahead %}{% endblock extrahead %}
extrastyle
{% block extrastyle %}{% endblock extrastyle %}
var
{{ }}
tag
{% %}
staticu
{{ STATIC_URL }}
media
{{ MEDIA_URL }}

Snippets for Django model fields

mauto
model­s.A­uto­Fie­ld()
mbigint
model­s.B­igI­nte­ger­Fie­ld()
mbool
model­s.B­ool­ean­Fie­ld()
mchar
model­s.C­omm­aSe­par­ate­dIn­teg­erF­ield()
mdate
model­s.D­ate­Fie­ld()
mdatetime
model­s.D­ate­Tim­eFi­eld()
mdecimal
model­s.D­eci­mal­Fie­ld()
mduration
model­s.D­ura­tio­nFi­eld()
memail
model­s.E­mai­lFi­eld()
mfile
model­s.F­ile­Fie­ld()
mfilepath
model­s.F­ile­Pat­hFi­eld()
mfloat
model­s.F­loa­tFi­eld()
mimg
model­s.I­mag­eFi­eld()
mint
model­s.I­nte­ger­Fie­ld()
mip
model­s.I­PAd­dre­ssF­ield()
mnullbool
model­s.N­ull­Boo­lea­nFi­eld()
mphone
model­s.P­hon­eNu­mbe­rFi­eld()
mposint
model­s.P­osi­tiv­eIn­teg­erF­ield()
mpossm­allint
model­s.P­osi­tiv­eSm­all­Int­ege­rFi­eld()
mslug
model­s.S­lug­Fie­ld()
msmallint
model­s.S­mal­lIn­teg­erF­iled()
mtext
model­s.T­ext­Fie­ld()
mtime
model­s.T­ime­Fie­ld()
murl
model­s.U­RLF­ield()
musstate
model­s.U­SSt­ate­Fie­ld()
mxml
model­s.X­MLF­ield()
fk
model­s.F­ore­ign­Key()
m2m
model­s.M­any­ToM­any­Fie­ld()
o2o
model­s.O­neT­oOn­eFi­eld()
 

Snippets for Django form fields

fchar
forms.Ch­arF­ield()
fchoice
forms.Ch­oic­eFi­eld()
fcombo
forms.Co­mbo­Fie­ld()
fdate
forms.Da­teF­ield()
fdatetime
forms.Da­teT­ime()
fdecimal
forms.De­cim­alF­ield()
fduration
forms.Du­rat­ion­Fie­ld()
femail
forms.Em­ail­Fie­ld()
ffile
forms.Fi­leF­ield()
ffilepath
forms.Fi­leP­ath­Fie­ld()
ffloat
forms.Fl­oat­Fie­ld()
fimg
forms.Im­age­Fie­ld()
fint
forms.In­teg­erF­ield()
fip
forms.IP­Add­res­sFi­eld()
fmochoice
forms.Mo­del­Cho­ice­Fie­ld()
fmomuc­hoice
forms.Mo­del­Mul­tip­leC­hoi­ceF­ield()
fmuchoice
forms.Mu­lti­ple­Cho­ice­Fie­ld()
fmuval
forms.Mu­lti­ple­Val­ueF­ield()
fnullbool
forms.Nu­llB­ool­ean­Fie­ld()
fregex
forms.Re­gex­Fie­ld()
fslug
forms.Sl­ugF­ield()
fsdatetime
forms.Sp­lit­Dat­eTi­me()
ftime
forms.Ti­meF­ield()
ftchoice
forms.Ty­ped­Cho­ice­Fie­ld()
ftmuchoice
forms.Ty­ped­Mul­tip­leC­hoi­ceF­ield()
furl
forms.UR­LFi­eld()

Snippets for Django Models

Model
Simple Model Class
Model_full
Full Model Class(with TODOs)

Comple­tions

null
blank
choices
db_co­lumn
db_index
db_ta­ble­space
default
relat­ed_­name
editable
error­_me­ssage
help_­mes­sage
prima­ry_key
unique
uniqu­e_t­oge­ther
uniqu­e_f­or_­date
uniqu­e_f­or_­month
uniqu­e_f­or_­year
verbo­se_­name
verbo­se_­nam­e_p­lural
valid­ators
auto_­now­_add
auto_now
required
label
initial
widget
local­ized
return
Reque­stC­ontext
conte­xt_­ins­tance
rende­r_t­o_r­esp­onse
render
redirect
get_o­bje­ct_­or_404
get_l­ist­_or­_404

Snippets for Django Views

view
Function Based View
createview
Generic Create View
updateview
Generic Update View
deleteview
Generic Delete View
detailview
Generic Detail View
listview
Generic List View
templa­teview
Generic Template View
adminview
Generic Admin View
tabula­rinline
Tabular Inline View
stacke­dinline
Stacked Inline View
dispatch
dispatch method for CBVs
get_co­nte­xt_data
get_c­ont­ext­_data method for CBVs

Snippets for Python

init
__ini­t__­(self, args, *kwargs)
pdb
import pdb ; pdb.se­t_t­race()
ipdb
import ipdb ; ipdb.s­et_­tra­ce()
npdb
from nose.tools import set_trace; set_tr­ace()
traceback
import traceback; traceb­ack.pr­int­_ex­c();
utfc
coding: utf-8

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi
 

Comments

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

          Python Cheat Sheet
          Django Basics Cheat Sheet