django10-cheat-sheet
add
divisibleby
floatformat
filesizeformat
get_digit
nth-rightmost digit from integer
pluralize
N
U
M
BERS
5
3
decimal_places
n
"y,ies"
default
default_if_none
yesno
stringformat
python “%” formatting
value
value
"yes,no,none"
"s"
escape
force_escape...
add
divisibleby
floatformat
filesizeformat
get_digit
nth-rightmost digit from integer
pluralize
N
U
M
BERS
5
3
decimal_places
n
"y,ies"
default
default_if_none
yesno
stringformat
python “%” formatting
value
value
"yes,no,none"
"s"
escape
force_escape
safe don’t escape
escapejs \x20 escapes
iriencode IRI to URI
urlencode %20 escapes
G
EN
ERA
L
ESC
A
PIN
G
DJANGO CHEAT SHEET
Version 1.0 www.mercurytide.co.uk/careers
Issue 4
{# one line comment #}
autoescape…
block…
comment…
cycle
debug
extends
filter...
firstof
for...
if…else…endif
ifchanged…
on/off
name
"one" "two" "three"
"template"
filter1|filter2
var1 var2 "default"
item in a_list
boolean expression
var
ifequal…
ifnotequal…
include
load
now
regroup
spaceless…
templatetag
open or close block, brace, variable, comment
url
widthratio
a ÷ b × c
with…
var1 var2
var1 var2
"template"
tag_library
"date format"
list_of_dicts by key as var
openblock
view arg,kwarg=value
a b c
var1.attr as var2
y
Y
YEA
R
99
1999
F
M
b
N
m
n
M
O
N
T
H
January
Jan
jan
Jan., Feb., March, May
01 to 12
1 to 12
d
j
S
D
AY
01 to 31
1 to 31
suffix: st, nd, rd or th
f
P
r
FO
RM
AT
S
1, 1:30
1 a.m., 1:30 p.m., noon
Thu, 21 Dec 2000 16:01:07 +0200
L
t
M
ISC
is leap year: True or False
length of month: 28 to 31
z
W
M
ISC
day of year: 0 to 365
week number: 1 to 53
T
O
Z
T
IM
E
EST, MDT
+0200
-43200 to 43200 (seconds)
a
A
A
M
&
PM
a.m. or p.m.
AM or PM
h
g
H
G
H
O
U
R
01 to 12
1 to 12
00 to 23
0 to 23
i MIN
&
SEC
00 to 59
s 00 to 59
D
AY O
F
W
EEK
Friday
Fri
0 (Sun) to 6 (Sat)
Template date formats lowerupper
title
capfirst
slugify
ljust
rjust
center
wordwrap
wordcount
striptags
removetags
truncatewords
truncatewords_html
adds closing tags
linebreaks
linebreaksbr
urlize
urlizetrunc
cut
strips "x" from string
linenumbers
phone2numeric
pprint
T
EX
T
FO
RM
AT
T
IN
G
width
width
width
width
"a img"
number
number
max_length
"x"
date
time
timesince
timeuntil
D
AT
ES
&
T
IM
ES
"date_format"
"date_format"
datetime
datetime
first
last
random
length
length_is
join
make_list
makes list of digits/characters
slice
dictsort
dictsortreversed
unordered_list
adds
tags
number
", "
"1:5"
"key"
"key"
LIST
S
Template filters
date_hierarchy
form
fieldsets
fields
filter_horizontal
filter_vertical
list_display
list_display_links
list_filter
list_per_page
="date_field"
=FormClass
=[("Details", {"fields": ("name",)})]
=list_of_field_names
=False
=False
=list_of_field_names
=list_of_field_names
=list_of_field_names
=100
list_select_related
inlines
ordering
prepopulated_fields
radio_fields
raw_id_fields
save_as
save_on_top
search_fields
=False
=list_of_InlineClasses
=list_of_field_names
={"slug": ("name",)}
={"agree": admin.VERTICAL}
=list_of_fk_fields
=False
=False
=list_of_field_names
ModelAdmin options
model
fk_name
formset
extra
max_num
template
verbose_name
verbose_name_plural
InlineModelAdmin options
=Book
="book"
=BaseInlineFormSet
=3
=0
="template"
="Book"
="Books"
Template tags ... - end tag required
Meta class options
Copyright 2008 Mercurytide Ltd.
Released under the Creative Commons
Attribution-Share Alike 2.5 UK: Scotland Licence.
abstract
db_table
db_tablespace
get_latest_by
order_with_respect_to
ordering
permissions
unique_together
verbose_name
verbose_name_plural
Model fields
BooleanField
NullBooleanField
CharField
TextField
SlugField
FilePathField
IntegerField
PositiveIntegerField
AutoField
DecimalField
FloatField
SmallIntegerField
PositiveSmallIntegerField
CommaSeparatedIntegerField
DateField
Form fields
BooleanField
NullBooleanField
CharField
IntegerField
DecimalField
FloatField
DateField
DateTimeField
TimeField
ChoiceField
MultipleChoiceField
IPAddressField
FileField
ImageField
FilePathField
RegexField
ModelChoiceField
ModelMultipleChoiceField
URLField
EmailField
DateTimeField
TimeField
EmailField
IPAddressField
URLField
FileField
ImageField
XMLField
=False
=False
=list_of_tuples
="column_name"
=False
="tablespace_name"
=value_or_func
=True
="text"
=False
=False
="date_field"
="date_field"
="date_field"
=False
="table_name"
="tablespace_name"
="field_name"
="fk_field_name"
=list_of_columns
=list_of_tuples
=list_of_tuples
="Model"
="Models"
Model fields common options
Relational model fields
DJANGO CHEAT SHEET
Version 1.0
null
blank
choices
db_column
db_index
db_tablespace
default
editable
help_text
primary_key
unique
unique_for_date
unique_for_month
unique_for_year
ForeignKey(model)
ManyToManyField(model)
OneToOneField(model)
GenericForeignKey("content_type_field",
"object_id_field")
Form fields common options
required
label
initial
widget
help_text
error_messages
Form error_messages keys
required
max_length
min_length
invalid
invalid_choice
max_value
min_value
max_digits
max_decimal_places
max_whole_digits
missing
empty
invalid_image
invalid_list
invalid_link
max_length
max_length
path
match
recursive
max_length
max_digits
decimal_places
max_length
auto_now
auto_now_add
max_length
min_length
max_value
min_value
max_value
min_value
max_digits
decimal_places
max_value
min_value
input_formats
input_formats
input_formats
choices
choices
path
match
recursive
regex
max_length
min_length
queryset
empty_label
cache_choices
queryset
cache_choices
max_length
min_length
verify_exists
validator_user_agent
max_length
min_length
="----"
=False
=False
=False
="/home/images"
=r"\.jpg$"
=False
=list_of_formats
=list_of_formats
=list_of_formats
=list_of_tuples
=list_of_tuples
=50
="/home/images"
=r"\.jpg$"
=True
=100
=10
=2
=50
=False
=False
=False
=False
=False
=False
=75
=True
=200
="uploads/"
=100
=FileSystemStorage
="uploads/"
=100
=FileSystemStorage
="field_name"
="field_name"
=path_to_RelaxNG_schema
auto_now
auto_now_add
auto_now
auto_now_add
max_length
verify_exists
max_length
upload_to
max_length
storage
upload_to
max_length
storage
height_field
width_field
schema_path
related_name
limit_choices_to
to_field
related_name
limit_choices_to
through
symmetrical
parent_link
="model_set"
=query_kwargs
="key_field"
="model_set"
=query_kwargs
="IntermediateModel"
=True
="field"
=True
="Field name"
={}
=Widget
="text"
={}
Issue 4
本文档为【django10-cheat-sheet】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。