Snippet List
**preview_template.py** allows you to test a Django template located in the current working directory (first argument). The template is rendered with the given context (second argument, *optional*), and the result is immediately piped into the browser with the [bcat](http://rtomayko.github.io/bcat/) utility.
**Usage:**
python preview_template.py [template name] [context]
**Example:**
python preview_template.py template.html "{'username': 'Његош'}"
The Django admin site has a feature to filter objects in change list by parameters supplied in the query string. Particularly, parameters such as date\__gte and date\__lte can be used.
This example is for filtering objects in change list by a date range (the date field is called expiration_date, but you can, of course, use any other name).
As the server side (Django) already supports such filtering, all you need to do is to edit this for your needs (you can also add some DRY if you want) and put it into templates/admin/app_name/model_name/change_list.html.
Some CSS for better layout:
div.date_filter select#from_month, div.date_filter select#to_month {
margin-left: 0;
}
div.date_filter label {
margin-right: 5px;
}
- javascript
- date
- jquery
- html
- change_list
- change-list
- date-range
aruseni has posted 2 snippets.