In smarty templates you can use raw PHP code in a template by placing it within the "literal" template tag:
{literal}
echo 'hello world';
{/literal}
How can you use raw python code in a Django template?
Put your code in some directory outside of the document root, such as /home/mycode . These files are: The outer mysite/ root directory is a container for your project. Its name doesn't matter to Django; you can rename it to anything you like.
What does {{ name }} this mean in Django Templates? {{ name }} will be the output. It will be displayed as name in HTML. The name will be replaced with values of Python variable.
You can't, that's why you have to create custom template tag which runs the functionality. Here's more information on how to do that:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With