Generative Artificial Intelligence: How generative AI works.pdf
Â
Django10 cheat-sheet-grayscale
1. Template filters
Iss
ue
4
DJANGO CHEAT SHEET default value escape
force_escape
GENERAL
default_if_none value
Version 1.0
ESCAPING
www.mercurytide.co.uk/careers yesno "yes,no,none" safe don’t escape
stringformat "s" escapejs x20 escapes
python “%” formatting
iriencode IRI to URI
Template tags ... - end tag required
urlencode %20 escapes
first
{# one line comment #} ifequal… var1 var2 last add 5
autoescape… on/off ifnotequal… var1 var2 random divisibleby 3
block… name include "template" length
NUMBERS
floatformat decimal_places
comment… load tag_library length_is number filesizeformat
cycle "one" "two" "three" now "date format" join ", " get_digit n
LISTS
debug regroup list_of_dicts by key as var make_list nth-rightmost digit from integer
extends "template" spaceless… makes list of digits/characters pluralize "y,ies"
filter... filter1|filter2 templatetag openblock slice "1:5"
open or close block, brace, variable, comment date "date_format"
firstof var1 var2 "default" dictsort "key"
url view arg,kwarg=value time "date_format"
& TIMES
dictsortreversed "key"
DATES
for... item in a_list
widthratio abc timesince datetime
if…else…endif boolean expression a÷b×c
unordered_list
adds <li> tags timeuntil datetime
ifchanged… var with… var1.attr as var2
lower
Template date formats upper
h 01 to 12 d 01 to 31 F January T EST, MDT title
TIME
DAY
g 1 to 12 j 1 to 31 M Jan O +0200 capfirst
HOUR
H 00 to 23 S suffix: st, nd, rd or th b jan slugify
MONTH
Z -43200 to 43200 (seconds)
G 0 to 23 Friday N Jan., Feb., March, May ljust width
f 1, 1:30
FORMATS
DAY OF
WEEK
Fri m 01 to 12 rjust width
i 00 to 59 P 1 a.m., 1:30 p.m., noon
& SEC
MIN
0 (Sun) to 6 (Sat) n 1 to 12 center width
s 00 to 59 r Thu, 21 Dec 2000 16:01:07 +0200
wordwrap width
a a.m. or p.m. z day of year: 0 to 365 y 99 L is leap year: True or False
TEXT FORMATTING
YEAR
wordcount
MISC
& PM
MISC
AM
A AM or PM W week number: 1 to 53 Y 1999 t length of month: 28 to 31
striptags
removetags "a img"
ModelAdmin options InlineModelAdmin options truncatewords number
model truncatewords_html number
date_hierarchy ="date_field" list_select_related =False =Book
adds closing tags
form =FormClass inlines =list_of_InlineClasses fk_name ="book"
linebreaks
fieldsets =[("Details", {"fields": ("name",)})] ordering =list_of_field_names formset =BaseInlineFormSet
linebreaksbr
fields =list_of_field_names prepopulated_fields ={"slug": ("name",)} extra =3
urlize
filter_horizontal =False radio_fields ={"agree": admin.VERTICAL} max_num =0
urlizetrunc max_length
filter_vertical =False raw_id_fields =list_of_fk_fields template ="template"
cut "x"
list_display =list_of_field_names save_as =False verbose_name ="Book" strips "x" from string
list_display_links =list_of_field_names save_on_top =False verbose_name_plural ="Books" linenumbers
list_filter =list_of_field_names search_fields =list_of_field_names phone2numeric
list_per_page =100 pprint