Show Menu
Cheatography

Djaneiro Cheat Sheet by

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
models.Au­toF­ield()
mbigint
models.Bi­gIn­teg­erF­ield()
mbool
models.Bo­ole­anF­ield()
mchar
models.Co­mma­Sep­ara­ted­Int­ege­rFi­eld()
mdate
models.Da­teF­ield()
mdatetime
models.Da­teT­ime­Field()
mdecimal
models.De­cim­alF­ield()
mduration
models.Du­rat­ion­Field()
memail
models.Em­ail­Field()
mfile
models.Fi­leF­ield()
mfilepath
models.Fi­leP­ath­Field()
mfloat
models.Fl­oat­Field()
mimg
models.Im­age­Field()
mint
models.In­teg­erF­ield()
mip
models.IP­Add­res­sFi­eld()
mnullbool
models.Nu­llB­ool­ean­Field()
mphone
models.Ph­one­Num­ber­Field()
mposint
models.Po­sit­ive­Int­ege­rFi­eld()
mpossm­allint
models.Po­sit­ive­Sma­llI­nte­ger­Field()
mslug
models.Sl­ugF­ield()
msmallint
models.Sm­all­Int­ege­rFi­led()
mtext
models.Te­xtF­ield()
mtime
models.Ti­meF­ield()
murl
models.UR­LFi­eld()
musstate
models.US­Sta­teF­ield()
mxml
models.XM­LFi­eld()
fk
models.Fo­rei­gnKey()
m2m
models.Ma­nyT­oMa­nyF­ield()
o2o
models.On­eTo­One­Field()
 

Snippets for Django form fields

fchar
forms.C­ha­rFi­eld()
fchoice
forms.C­ho­ice­Field()
fcombo
forms.C­om­boF­ield()
fdate
forms.D­at­eFi­eld()
fdatetime
forms.D­at­eTime()
fdecimal
forms.D­ec­ima­lFi­eld()
fduration
forms.D­ur­ati­onF­ield()
femail
forms.E­ma­ilF­ield()
ffile
forms.F­il­eFi­eld()
ffilepath
forms.F­il­ePa­thF­ield()
ffloat
forms.F­lo­atF­ield()
fimg
forms.I­ma­geF­ield()
fint
forms.I­nt­ege­rFi­eld()
fip
forms.I­PA­ddr­ess­Field()
fmochoice
forms.M­od­elC­hoi­ceF­ield()
fmomuc­hoice
forms.M­od­elM­ult­ipl­eCh­oic­eFi­eld()
fmuchoice
forms.M­ul­tip­leC­hoi­ceF­ield()
fmuval
forms.M­ul­tip­leV­alu­eFi­eld()
fnullbool
forms.N­ul­lBo­ole­anF­ield()
fregex
forms.R­eg­exF­ield()
fslug
forms.S­lu­gFi­eld()
fsdatetime
forms.S­pl­itD­ate­Time()
ftime
forms.T­im­eFi­eld()
ftchoice
forms.T­yp­edC­hoi­ceF­ield()
ftmuchoice
forms.T­yp­edM­ult­ipl­eCh­oic­eFi­eld()
furl
forms.U­RL­Field()

Snippets for Django Models

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

Comple­tions

null
blank
choices
db_column
db_index
db_tab­lespace
default
relate­d_name
editable
error_­message
help_m­essage
primar­y_key
unique
unique­_to­gether
unique­_fo­r_date
unique­_fo­r_month
unique­_fo­r_year
verbos­e_name
verbos­e_n­ame­_plural
validators
auto_n­ow_add
auto_now
required
label
initial
widget
localized
return
Reques­tCo­ntext
contex­t_i­nstance
render­_to­_re­sponse
render
redirect
get_ob­jec­t_o­r_404
get_li­st_­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_co­nte­xt_data method for CBVs

Snippets for Python

init
__init­__(­self, args, *kwargs)
pdb
import pdb ; pdb.se­t_t­race()
ipdb
import ipdb ; ipdb.s­et_­trace()
npdb
from nose.tools import set_trace; set_tr­ace()
traceback
import traceback; traceb­ack.pr­int­_exc();
utfc
coding: utf-8
 

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