Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Djaneiro Cheat Sheet

by Admoroux (Admoroux) via cheatography.com/25539/cs/6720/

Snippets for Django templates Snippets for Django templates (cont)

autoescape {% autoescape %} {% autoescape %} with {% with as %} {% endwith %}

block {% block %} {% endblock %} trans {% trans %}

comment {% comment %} {% endcomment %} blocktrans {% blocktrans with as %} {% endblo​cktrans %

csrf {% csrf_token %} }

cycle {% cycle %}
Non-of​ficial snippets for templates
debug {% debug %}
super {{ block.s​uper }}
ext {% extends "​" %}
extrahead {% block extrahead %}{% endblock extrahead %}
extends {% extends "​" %}
extrastyle {% block extrastyle %}{% endblock extrastyle %}
filter {% filter %} {% endfilter %}
var {{ }}
firstof {% firstof %}
tag {% %}
for {% for in %} {% endfor %}
staticu {{ STATIC_URL }}
fore {% for in %} {% empty %} {% endfor %}
media {{ MEDIA_URL }}
if {% if %} {% endif %}

ifchanged {% ifchanged %} {% endifc​hanged %} Snippets for Django model fields


ife {% if %} {% else %} {% endif %} mauto models.Au​toF​ield()
ifelse {% if %} {% else %} {% endif %} mbigint models.Bi​gIn​teg​erF​ield()
ifeq {% ifequal %} {% endifequal %} mbool models.Bo​ole​anF​ield()
ifequal {% ifequal %} {% endifequal %} mchar models.Co​mma​Sep​ara​ted​Int​ege​rFi​e
ifnotequal {% ifnotequal %} {% endifn​otequal %} ld()

inc {% include %} mdate models.Da​teF​ield()

include {% include %} mdatetime models.Da​teT​ime​Field()

load {% load %} mdecimal models.De​cim​alF​ield()

now {% now "​" %} mduration models.Du​rat​ion​Field()

regroup {% regroup by as %} memail models.Em​ail​Field()

spaceless {% spaceless %} {% endspa​celess %} mfile models.Fi​leF​ield()

ssi {% ssi %} mfilepath models.Fi​leP​ath​Field()

static {% static %} mfloat models.Fl​oat​Field()

templa​tetag {% templa​tetag %} mimg models.Im​age​Field()

url {% url %} mint models.In​teg​erF​ield()

verbatim {% verbatim %} {% endver​batim %} mip models.IP​Add​res​sFi​eld()

widthratio {% widthratio %}

By Admoroux (Admoroux) Published 29th April, 2017. Sponsored by Readable.com


cheatography.com/admoroux/ Last updated 29th April, 2017. Measure your website readability!
retrofrikis.com/ Page 1 of 3. https://readable.com
Djaneiro Cheat Sheet
by Admoroux (Admoroux) via cheatography.com/25539/cs/6720/

Snippets for Django model fields (cont) Snippets for Django form fields (cont)

mnullbool models.Nu​llB​ool​ean​Field() fmuchoice forms.M​ul​tip​leC​hoi​ceF​ield()

mphone models.Ph​one​Num​ber​Field() fmuval forms.M​ul​tip​leV​alu​eFi​eld()

mposint models.Po​sit​ive​Int​ege​rFi​eld() fnullbool forms.N​ul​lBo​ole​anF​ield()

mpossm​allint models.Po​sit​ive​Sma​llI​nte​ger​Fie fregex forms.R​eg​exF​ield()


ld() fslug forms.S​lu​gFi​eld()
mslug models.Sl​ugF​ield() fsdatetime forms.S​pl​itD​ate​Time()
msmallint models.Sm​all​Int​ege​rFi​led() ftime forms.T​im​eFi​eld()
mtext models.Te​xtF​ield() ftchoice forms.T​yp​edC​hoi​ceF​ield()
mtime models.Ti​meF​ield() ftmuchoice forms.T​yp​edM​ult​ipl​eCh​oic​eFi​eld
murl models.UR​LFi​eld() ()

musstate models.US​Sta​teF​ield() furl forms.U​RL​Field()

mxml models.XM​LFi​eld()
Snippets for Django Models
fk models.Fo​rei​gnKey()
Model Simple Model Class
m2m models.Ma​nyT​oMa​nyF​ield()
Model_full Full Model Class(with TODOs)
o2o models.On​eTo​One​Field()

Comple​tions
Snippets for Django form fields
null blank choices
fchar forms.C​ha​rFi​eld()
db_column db_index db_tab​lespace
fchoice forms.C​ho​ice​Field()
default relate​d_name editable
fcombo forms.C​om​boF​ield()
error_​message help_m​essage primar​y_key
fdate forms.D​at​eFi​eld()
unique unique​_to​geth unique​_fo​r_dat
fdatetime forms.D​at​eTime()
er e
fdecimal forms.D​ec​ima​lFi​eld()
unique​_fo​r_month unique​_fo​r_ye verbos​e_name
fduration forms.D​ur​ati​onF​ield()
ar
femail forms.E​ma​ilF​ield()
verbos​e_n​ame​_plu validators auto_n​ow_add
ffile forms.F​il​eFi​eld() ral
ffilepath forms.F​il​ePa​thF​ield() auto_now required label
ffloat forms.F​lo​atF​ield() initial widget localized
fimg forms.I​ma​geF​ield() return Reques​tCo​ntex contex​t_i​nstan
fint forms.I​nt​ege​rFi​eld() t ce

fip forms.I​PA​ddr​ess​Field() render​_to​_re​spon render redirect

fmochoice forms.M​od​elC​hoi​ceF​ield() se

fmomuc​hoice forms.M​od​elM​ult​ipl​eCh​oic​eFi​el get_ob​jec​t_o​r_40 get_li​st_​or_404

d() 4

By Admoroux (Admoroux) Published 29th April, 2017. Sponsored by Readable.com


cheatography.com/admoroux/ Last updated 29th April, 2017. Measure your website readability!
retrofrikis.com/ Page 2 of 3. https://readable.com
Djaneiro Cheat Sheet
by Admoroux (Admoroux) via cheatography.com/25539/cs/6720/

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

By Admoroux (Admoroux) Published 29th April, 2017. Sponsored by Readable.com


cheatography.com/admoroux/ Last updated 29th April, 2017. Measure your website readability!
retrofrikis.com/ Page 3 of 3. https://readable.com

You might also like