Skip to content

Commit f04037a

Browse files
author
Noah Lloyd-Edelman
committed
More notes.
1 parent 44aef72 commit f04037a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

django.md

+31
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,37 @@ def DetailView(generic.DetailView):
254254
<a href="{{ object.get_absolute_url }}">{{ object.name }}</a>
255255
````
256256

257+
### templates
258+
259+
````
260+
django.contrib.humanize
261+
````
262+
263+
````
264+
{% extends 'base.html' %}
265+
266+
{% block title %}
267+
{{ section.title }}
268+
{% endblock %}
269+
270+
{% block story %}
271+
{% for story in story_list %}
272+
{% story.headline|upper %}
273+
{% endfor %}
274+
{% endblock %}
275+
````
276+
277+
* an empty string is used if a variable is not found {{ var.attr }}
278+
* filers = |var. for example {{ bio|truncatewords:30 }}{{ value|default:"nothing" }}
279+
* others can be [found here](https://docs.djangoproject.com/en/1.11/ref/templates/builtins/#ref-templates-builtins-filters)
280+
281+
command | description
282+
--- | ---
283+
intcomma | adds commas to numbers
284+
naturalday | yesterday, today, tomorrow for dates
285+
naturaltime | takes string and returns how long ago it happened
286+
ordinal | 1st, 2nd, 3rd from ints
287+
257288
## Project folder
258289

259290
### urls.py

0 commit comments

Comments
 (0)