Created
December 22, 2013 09:38
-
-
Save matuu/8080312 to your computer and use it in GitHub Desktop.
django templatetags: query filters model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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