You need to pass a dictionary as a second parameter to
the render_to_response method with the variables that you wish to access in
the template.

for example:

return render_to_response('index.html', {"people_info": pers})

that way you can access the variable "people_info" in the template.


On Thu, Oct 16, 2014 at 8:26 AM, Sachin Tiwari <sachin.tiwar...@gmail.com>
wrote:

> Hi ,
>
> I have below lines in view.py and acesssing this variable in html but not
> getting output,
>
> def index (request):
>     pers = list(PersonInfo.objects.filter())
>
>     return render_to_response('index.html')
>
> html code
>
>                 <ul>
>                      <div class="col-md-12">
>                      {% for id in pers %}
>                         <button type="button" class="btn
> btn-success">{{id.personid}}</button>
>                         <button type="button" class="btn btn-danger">
> {{id.personid}}</button>
>                         <button type="button" class="btn
> btn-success">{{id.personid}}</button>
>                         <button type="button" class="btn
> btn-warning">{{id.personid}}</button>
>                     {% endfor %}
>                      </div>
>                   </ul>
>
>
> But it is not displaying buttons on my page
>
>
>  --
> 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/384525cf-534a-4f8c-b177-f0cd9401a5f1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/384525cf-534a-4f8c-b177-f0cd9401a5f1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALn3ei1k4-gFR0NONxNLcrUVGZGqCmLy3LhuWYde4KU-MZby6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to