djangosnippets.org: Latest snippets tagged with 'arguments'https://djangosnippets.org/tags/arguments/2009-06-24T00:31:22.031915-05:00A tip for preserving GET arguments with pagination
2009-06-24T00:31:22.031915-05:00achimnolhttps://djangosnippets.org/snippets/1592/<p>This snippet shows a way to preserve GET arguments with pagination. Many people make mistakes to omit the query arguments besides page arguments for the pagination, and making sure correct may sphagettize your code.</p>
Freely redistributablePassing values to a method from a template
2008-03-16T22:51:53.597608-05:00miracle2khttps://djangosnippets.org/snippets/647/<p>A simple trick to let a function be called with exactly ONE argument from a Django template, by passing it via an attribute. Example:</p>
<pre><code>class SearchResult(object):
@template_callable
def highlighted(self, field):
return self._xappy_result.highlight(field)
result = SearchResult()
result.highlighted.title
{{ result.highlighted.title }}
</code></pre>
Freely redistributable