Roshan Book

My Tech Notebook

Django -Tempelate tag cheatsheet


This post was originally published at https://code.djangoproject.com/wiki/DjangoCheatSheet

 

Template Tags Cheat Sheet

Inheritance and Inclusion

  • {% extends “base.html “%}
  • {% block content %} … {% endblock %} or {% block content %} … {% endblock content %}
  • {% include “foo/bar.html” %}
  • {% ssi /home/html/ljworld.com/includes/right_generic.html %}

Filters and Tags

  • {% load <tag_or_filter_lib> %}
  • {% filter <filter>[|<filter>…] %}

Control

  • {% for o in some_list %} … {% endfor %}
  • {% ifchanged %} (Content to check status of) {% endifchanged %}
  • {% if %} … {% endif %}
  • {% if[not]equal user.id comment.user_id %} … [{% else %}] … {% endif[not]equal %}
  • {% cycle row1,row2 %}
  • {% cycle row1,row2 as rowcolors %} {% cycle rowcolors %}
  • {% firstof var1 var2 var3 %}
  • {% regroup people by gender as grouped %} … {% for group in grouped %} {{ group.grouper }} …

Others

  • {% templatetag (openblock|closeblock|openvariable|closevariable|openbrace|closebrace) %}
  • {% widthratio this_value max_value 100 %}
  • It is {% now “jS F Y H:i” %}
  • {% spaceless %} … {% endspaceless %}

One response to “Django -Tempelate tag cheatsheet

  1. nbevulrbn December 14, 2011 at 7:18 am

    Pm7pgW igdklswbfhym, [url=http://lrumyxtkppid.com/]lrumyxtkppid[/url], [link=http://ejhdmtjmnrrq.com/]ejhdmtjmnrrq[/link], http://ljmmtaddwuch.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: