Context

is a class used to represent the variables for a template.

Pass it to a Python dictionary containing the names of the variables and their values.

———-

e.g., the below Context

{‘card_list’:Card.objects.all(), ‘user’=request.user}

——————–

this will go to template and used

——————–

{% if user.is_authenticated %}
Welcome {{ user }} <br></br>
<a href=”{% url logout %}”>Logout</a>
{% else %}
<a href=”{% url login %}”>Login</a> |
<a href=”{% url signup %}”> Signup </a>
{% endif %}

{%for card in card_list %}
<h2> <a href=”{{card.get_absolute_url}}”> {{card.name}}</a></h2>
<p>{{card.description}}</p>

{%endfor%}

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2011 Web Oom Suffusion theme by Sayontan Sinha
Switch to our mobile site
Top Footer