Skip to content Skip to sidebar Skip to footer

Print The Value Of A Variable In Python/django?

In PHP I'm used to being able to do print $var or print_r($var). I can print variables in my views in python but they end up in my cmd window not on the page itself. This is fine f

Solution 1:

<html>
{{ this_is_my_variable_that_is_passed_to_my_view }}
</html>

the {{ allow variable access to the item which will call the items __unicode__ function if it exists otherwise it will call its __str__ function

Solution 2:

{{ your_variable }} will print the value.

https://docs.djangoproject.com/en/dev/ref/templates/api/#basics

Post a Comment for "Print The Value Of A Variable In Python/django?"