Skip to content

Instantly share code, notes, and snippets.

@matuu
Created December 22, 2013 09:38
Show Gist options
  • Select an option

  • Save matuu/8080312 to your computer and use it in GitHub Desktop.

Select an option

Save matuu/8080312 to your computer and use it in GitHub Desktop.
django templatetags: query filters model
@register.assignment_tag
def query(qs, **kwargs):
""" template tag which allows queryset filtering.
Usage:
{% load query from operations %}
{% query operations description="some things" as records %}
{% for r in records %}
...
{% endfor %}
"""
return qs.filter(**kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment