djangosnippets.org: Latest snippets tagged with 'argument'https://djangosnippets.org/tags/argument/2018-01-05T08:18:56.516304-06:00TemplateTag 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 redistributablePersistent Params Decorator
2009-08-06T04:27:03.513534-05:00achimnolhttps://djangosnippets.org/snippets/1670/<p>This snippet helps preserving query parameters such as page number when the view perform redirects.</p>
<p>It does not support hooking templates and contexts currently.</p>
Freely redistributable