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?