Show Menu
Cheatography

django cup sheet Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Template filters

|lower
|date: format
|upper
|time: format
r |title
|times­ince[: datetime]
|capfirst
|length
|slugify
|lengt­h_is: length
|ljust: width
|first
|rjust: width
|last
|center: width
|random
|wordwrap: width
|join: string
|striptags
|slice: "­1:9­"
|cut: substring
|divis­ibleby: number
|trunc­ate­chars: count
|float­for­mat[: decima­l_p­laces]

QuerySet API

all
filter
filter­(**­kwargs)
exclude
exclud­e(**­kw­args)
annotate
annotate( models.Co­unt­('c­ost') )
order_by
*field­s_str]
reverse
distinct
values
*field­s_str
values­_list
*field­s_str
date(time)
dates(­field, kind, order)
none
extra
extra(­sel­ect={})
create
create( **kwargs )
get
get( **kwargs )
get_or­_create
get_or­_cr­eate( **kwargs )
count
latest
aggregate
aggregate( models.Co­unt­('e­ntry') )
delete
 

Field Lookups

__exact
__iexact
Case Insens­itive
__contains
__icon­tains
__in
Pass in a list
__gt, __gte, __lt, __lte
__star­tswith, __ista­rts­with, __ends­with, __iend­swith
__range
(inclu­sive) =(X, Y)
__year, __month, __day, __hour, __minute, __second
__week_day
1=Sun, 7=Sat
__isnull
__regex

Django templates

{% cycle %}
{% debug %}
{% extends "­­" %}
{% filter %} {% endfilter %}
{% firstof %}
{% for in %} {% empty %} {%endfor%}
{% ifchanged %} {%endi­fc­­han­ged%}
{% ifequal %} {% endifequal %}
{% include %}
{% now "­­" %}
{% regroup by as %}
{% spaceless %} {% endspa­­celess %}
{% ssi %}
{% url %}
{% verbatim %} {% endver­­batim %}
{% with as %} {% endwith %}
{% blocktrans with as %} {% endblo­­ck­trans %}