https://djangosnippets.org/snippets/2619/
According to above snippet if we access {{ counter_var }}
in template after initializing it should return previous count. But in my case it does not return anything.
template code
<div class="question_number pull-left">Q{% counter %}. </div>
...
<script>var no_of_questions={{ counter_var }}</script>
Template tag is registered and it prints correctly Q<count>.
except counter_var
. Even I tried by setting context variable counter_var from view as {'counter_var':0,...}
then it returns '0'.
How to get it working so that it returns previous counter?
e.g.
Q1.
Q2.
then counter_var
should return 2 instead of nothing.
Django: 1.8.6
Python: 2.7
Note: I asked same question on stackoverflow but no help till now.
https://djangosnippets.org/snippets/2619/
According to above snippet if we access
{{ counter_var }}
in template after initializing it should return previous count. But in my case it does not return anything.
template code
<div class="question_number pull-left">Q{% counter %}. </div> ... <script>var no_of_questions={{ counter_var }}</script>
Template tag is registered and it prints correctly
Q<count>.
exceptcounter_var
. Even I tried by setting context variable counter_var from view as{'counter_var':0,...}
then it returns '0'.How to get it working so that it returns previous counter?
e.g.Q1. Q2.
then
counter_var
should return 2 instead of nothing.Django: 1.8.6
Python: 2.7
Note: I asked same question on stackoverflow but no help till now.
SO link: http://stackoverflow.com/questions/34894964/why-counter-tag-is-not-working-as-expected-in-djangoI am using two for loop one is for main question and another one is for sub questions.
Why? We have some comprehension type question, in comprehension type question there could be more than one questions so one outer for loop is running for main question and another one is sub questions.
--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/MxHQS3S_u7Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWvxZS4sTeLbbOqYRuFP3kSzgPiT84%3DatQpq6HH0JCfTw%40mail.gmail.com.