IS

SU

BUILT-IN TEMPLATE FILTERS

DJANGO CHEAT SHEET
version 0.95 FIELD TYPES
AutoField BooleanField CharField maxlength CommaSeparatedIntegerField maxlength DateField auto_now auto_now_add DateTimeField auto_now auto_now_add EmailField FileField upload_to FilePathField path match recursive FloatField max_digits decimal_places ImageField upload_to IntegerField IPAddressField NullBooleanField PhoneNumberField PositiveIntegerField PositiveSmallIntegerField SlugField maxlength prepopulate_from SmallIntegerField TextField TimeField auto_now auto_now_add URLField verify_exists USStateField XMLField schema_path

E

3

add addslashes capfirst center

phone2numeric pluralize pprint random “y,ies”

FIELD OPTIONS
null blank choices core db_column db_index default editable help_text primary_key radio_admin unique unique_for_date unique_for_month unique_for_year validator_list verbose_name field_name field_name field_name

BUILT-IN TEMPLATE TAGS
block comment cycle debug extends filter firstof for ... in ... if ifchanged ifequal ifnotequal include load now regroup spaceless ssi templatetag

cut date default default_if_none

arg format_string default_value default_value list_of_dicts list_of_dicts divisor

removetags rjust slice slugify stringformat striptags time timesince timeuntil title truncatewords

tags_to_remove field_size

row1,row2,row3 template_name filter |filter var1 var2 var3

dictsort dictsortreversed divisibleby escape filesizeformat first fix_ampersands floatformat

original_date original_date truncate_after

decimal_places which_digit

unordered_list upper urlencode urlize

var1 var2 var1 var2 template_name library1 library2 format_string

get_digit join length length_is linebreaks linebreaksbr linenumbers

expected_length

urlizetrunc wordcount wordwrap yesno

truncate_at wrap_at
“yes,no,maybe”

filename parsed

ljust lower make_list

field_size

ADMIN CLASS OPTIONS
date_hierarchy fields fields classes description js list_display list_display_links list_filter list_per_page list_select_related ordering save_as save_on_top search_fields

widthratio

META CLASS OPTIONS
db_table get_latest_by order_with_respect_to ordering permissions unique_together verbose_name verbose_name_plural

LEGEND
boolean dictionary integer time/date string tuple/list float
Also {# #} in development version See http://www.djangoproject.com/ documentation/templates/#now In development version only. See http://docs.python.org/lib/ typesseq-strings.html.

Copyright 2007 Mercurytide Ltd. Released under the Creative Commons Attribution-Share Alike 2.5 Licence.

Sign up to vote on this title
UsefulNot useful