djangosnippets.org: Latest snippets posted by michaeljtbrookshttps://djangosnippets.org/users/michaeljtbrooks/2018-01-05T08:18:56.516304-06:00michaeljtbrooksTemplateTag to call a method / function WITH arguments
2018-01-05T08:18:56.516304-06:00michaeljtbrookshttps://djangosnippets.org/snippets/10633/<p><strong>Callmethod</strong> - TemplateTag to call a method on an object with arguments from within a template</p>
<pre><code>{% callmethod hotel.room_price_for_night night_date="2018-01-02" room_type=room_type_context_var %}
## equals ##
>>> hotel.room_price_for_night(night_date="2018-01-02", room_type="standard") #Assuming "standard" is the value of room_type_context_var
</code></pre>
<p>Django doesn't allow calling a method with arguments in the template to ensure good separation …</p>
Freely redistributableTreePrint: Print nested lists, tuples, dicts
2012-06-19T10:32:04.380611-05:00michaeljtbrookshttps://djangosnippets.org/snippets/2773/<p>Displays nested lists / dicts / tuples in an aligned hierarchy to make debugging easy. Accepts all variable types, including nested lists with any mixture of tuples / dictionaries / lists / numbers / strings.</p>
<p>Analogous to the PHP print_r($var) function.</p>
Freely redistributable