You don't set the block tags in the view. You set the variables in the
view - in this example you set var_1_from_view (a single object) and
var_2_from_view (a collection/list of sorts)

<h2>

{% block side_hdr %}{% endblock%}

</h2>

{% block content %}

{{ var_1_from_view }}

{% for item in var_2_from_view %}
{{ item }}
{% endfor %}

{% endblock %}

When using GenericViews (like TemplateView) there is usually already a
named variable to be sent to the template, like

{{ object }}
{{ object.name }}
{% if object.colour is green %}
  {{ object.date_made }}
{% endif %}


This is probably the better example than TemplateViews

https://docs.djangoproject.com/en/dev/topics/class-based-views/generic-display/#generic-views-of-objects

cheers
L.

On 18 August 2014 20:58, Daniel Grace <danwgr...@gmail.com> wrote:
> I am struggling to understand block tags.  I have two block tags in my HTML
> template as follows:
>
> <h2>
> {% block side_hdr %}{% endblock%}
> </h2>
> {% block content %}{% endblock %}
>
> How (if possible) do I set these tags in my class based view?
>
> class TestView(TemplateView):
>     template_name = "base.html"
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ddde67b8-abd2-4608-b841-344204907621%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
You have to be really clever to come up with a genuinely dangerous
thought. I am disheartened that people can be clever enough to do that
and not clever enough to do the obvious thing and KEEP THEIR IDIOT
MOUTHS SHUT about it, because it is much more important to sound
intelligent when talking to your friends.
This post was STUPID.
-----------------------------------------------------------------------------------------------------------
The Most Terrifying Thought Experiment of All Time
http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiP_qfRLJYMWGBv%2BVaLSQFEEUg64FZitEXRzw82Mh-1TZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to