0% found this document useful (0 votes)
94 views

Djaneiro Cheat Sheet: by Via

This document contains Django template and model field snippets organized into the following sections: 1. Snippets for Django templates including tags for autoescape, block, comment, csrf, cycle, and more. 2. Snippets for Django model fields including auto, bigint, boolean, char, date, datetime, decimal, and more. 3. Snippets for Django form fields including char, choice, combo, date, datetime, decimal, duration, email, file, and more. 4. Snippets for Django views including function based views, generic class based views like CreateView, UpdateView, DeleteView, and more.

Uploaded by

Borort
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

Djaneiro Cheat Sheet: by Via

This document contains Django template and model field snippets organized into the following sections: 1. Snippets for Django templates including tags for autoescape, block, comment, csrf, cycle, and more. 2. Snippets for Django model fields including auto, bigint, boolean, char, date, datetime, decimal, and more. 3. Snippets for Django form fields including char, choice, combo, date, datetime, decimal, duration, email, file, and more. 4. Snippets for Django views including function based views, generic class based views like CreateView, UpdateView, DeleteView, and more.

Uploaded by

Borort
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Djaneiro Cheat Sheet

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

Snippets for Django templates Non-of​ficial snippets for templates

autoescape {% autoescape %} {% autoescape %} super {{ block.s​uper }}

block {% block %} {% endblock %} extrahead {% block extrahead %}{% endblock extrahead %}

comment {% comment %} {% endcomment %} extrastyle {% block extrastyle %}{% endblock extrastyle


%}
csrf {% csrf_token %}
var {{ }}
cycle {% cycle %}
tag {% %}
debug {% debug %}
staticu {{ STATIC_URL }}
ext {% extends "​" %}
media {{ MEDIA_URL }}
extends {% extends "​" %}

filter {% filter %} {% endfilter %}


Snippets for Django model fields
firstof {% firstof %}
mauto model​s.A​uto​Fie​ld()
for {% for in %} {% endfor %}
mbigint model​s.B​igI​nte​ger​Fie​ld()
fore {% for in %} {% empty %} {% endfor %}
mbool model​s.B​ool​ean​Fie​ld()
if {% if %} {% endif %}
mchar model​s.C​omm​aSe​par​ate​dIn​teg​erF​ield()
ifchanged {% ifchanged %} {% endifc​hanged %}
mdate model​s.D​ate​Fie​ld()
ife {% if %} {% else %} {% endif %}
mdatetime model​s.D​ate​Tim​eFi​eld()
ifelse {% if %} {% else %} {% endif %}
mdecimal model​s.D​eci​mal​Fie​ld()
ifeq {% ifequal %} {% endifequal %}
mduration model​s.D​ura​tio​nFi​eld()
ifequal {% ifequal %} {% endifequal %}
memail model​s.E​mai​lFi​eld()
ifnotequal {% ifnotequal %} {% endifn​otequal %}
mfile model​s.F​ile​Fie​ld()
inc {% include %}
mfilepath model​s.F​ile​Pat​hFi​eld()
include {% include %}
mfloat model​s.F​loa​tFi​eld()
load {% load %}
mimg model​s.I​mag​eFi​eld()
now {% now "​" %}
mint model​s.I​nte​ger​Fie​ld()
regroup {% regroup by as %}
mip model​s.I​PAd​dre​ssF​ield()
spaceless {% spaceless %} {% endspa​celess %}
mnullbool model​s.N​ull​Boo​lea​nFi​eld()
ssi {% ssi %}
mphone model​s.P​hon​eNu​mbe​rFi​eld()
static {% static %}
mposint model​s.P​osi​tiv​eIn​teg​erF​ield()
templa​tetag {% templa​tetag %}
mpossm​allint model​s.P​osi​tiv​eSm​all​Int​ege​rFi​eld()
url {% url %}
mslug model​s.S​lug​Fie​ld()
verbatim {% verbatim %} {% endver​batim %}
msmallint model​s.S​mal​lIn​teg​erF​iled()
widthratio {% widthratio %}
mtext model​s.T​ext​Fie​ld()
with {% with as %} {% endwith %}
mtime model​s.T​ime​Fie​ld()
trans {% trans %}
murl model​s.U​RLF​ield()
blocktrans {% blocktrans with as %} {% endblo​cktrans %}
musstate model​s.U​SSt​ate​Fie​ld()

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


cheatography.com/admoroux/ Last updated 29th April, 2017. Everyone has a novel in them. Finish Yours!
retrofrikis.com/ Page 1 of 3. https://apollopad.com
Djaneiro Cheat Sheet
by Admoroux (Admoroux) via cheatography.com/25539/cs/6720/

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

mxml model​s.X​MLF​ield() Model Simple Model Class

fk model​s.F​ore​ign​Key() Model_full Full Model Class(with TODOs)

m2m model​s.M​any​ToM​any​Fie​ld()
Comple​tions
o2o model​s.O​neT​oOn​eFi​eld()
null blank choices

Snippets for Django form fields db_co​lumn db_index db_ta​ble​space

fchar forms.Ch​arF​ield() default relat​ed_​name editable

fchoice forms.Ch​oic​eFi​eld() error​_me​ssage help_​mes​sage prima​ry_key

fcombo forms.Co​mbo​Fie​ld() unique uniqu​e_t​oge​ther uniqu​e_f​or_​date

fdate forms.Da​teF​ield() uniqu​e_f​or_​month uniqu​e_f​or_​year verbo​se_​name

fdatetime forms.Da​teT​ime() verbo​se_​nam​e_p​lural valid​ators auto_​now​_add

fdecimal forms.De​cim​alF​ield() auto_now required label

fduration forms.Du​rat​ion​Fie​ld() initial widget local​ized

femail forms.Em​ail​Fie​ld() return Reque​stC​ontext conte​xt_​ins​tance

ffile forms.Fi​leF​ield() rende​r_t​o_r​esp​onse render redirect

ffilepath forms.Fi​leP​ath​Fie​ld() get_o​bje​ct_​or_404 get_l​ist​_or​_404

ffloat forms.Fl​oat​Fie​ld()
Snippets for Django Views
fimg forms.Im​age​Fie​ld()
view Function Based View
fint forms.In​teg​erF​ield()
createview Generic Create View
fip forms.IP​Add​res​sFi​eld()
updateview Generic Update View
fmochoice forms.Mo​del​Cho​ice​Fie​ld()
deleteview Generic Delete View
fmomuc​hoice forms.Mo​del​Mul​tip​leC​hoi​ceF​ield()
detailview Generic Detail View
fmuchoice forms.Mu​lti​ple​Cho​ice​Fie​ld()
listview Generic List View
fmuval forms.Mu​lti​ple​Val​ueF​ield()
templa​teview Generic Template View
fnullbool forms.Nu​llB​ool​ean​Fie​ld()
adminview Generic Admin View
fregex forms.Re​gex​Fie​ld()
tabula​rinline Tabular Inline View
fslug forms.Sl​ugF​ield()
stacke​dinline Stacked Inline View
fsdatetime forms.Sp​lit​Dat​eTi​me()
dispatch dispatch method for CBVs
ftime forms.Ti​meF​ield()
get_co​nte​xt_data get_c​ont​ext​_data method for CBVs
ftchoice forms.Ty​ped​Cho​ice​Fie​ld()

ftmuchoice forms.Ty​ped​Mul​tip​leC​hoi​ceF​ield()
Snippets for Python
furl forms.UR​LFi​eld()
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()

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


cheatography.com/admoroux/ Last updated 29th April, 2017. Everyone has a novel in them. Finish Yours!
retrofrikis.com/ Page 2 of 3. https://apollopad.com
Djaneiro Cheat Sheet
by Admoroux (Admoroux) via cheatography.com/25539/cs/6720/

Snippets for Python (cont)

traceback import traceback; traceb​ack.pr​int​_ex​c();

utfc coding: utf-8

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


cheatography.com/admoroux/ Last updated 29th April, 2017. Everyone has a novel in them. Finish Yours!
retrofrikis.com/ Page 3 of 3. https://apollopad.com

You might also like