python - Passing a variable from view to HTML -


assuming in views.py have variable:

a = 5 

and want include information in html page can like:

 {%if = 5%}  something.  {%endif%} 

i wondering have pass render_to_response in order value a, or not @ possible?

you can add items context dictionary become available within template. see docs.

def some_view(request):     context = {         'a': 5     }      return render_to_response(         'my_template.html',         context,         context_instance=requestcontext(request)     ) 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -