Snippet List
The counter initializes the variable to 0, and next it increments one by one:
{% load counter_tag %}
{% for pet in pets %}
{% if pet.is_cat %}
{% counter cats %}
{% else %}
{% counter dogs %}
{% endif %}
{% endfor %}
# cats: {{cats}}
# dogs: {{dogs}}
- template
- django
- counter
- increment
- loop
This patch adds a new admin Filter, for Filtering nullable fields. It adds 3 possible choices: 'All' (no filter), 'Null' (it applies field__isnull=True filter), and 'With Value' (it filters null values).
This patch is interesting when you have a Integer or String fields and you want to filter wether a value is set or not. In other case, it would show too many filtering options.
Remember this is a patch and you must modify a django file in `django/contrib/admin/filterspecs.py`
bcurtu has posted 2 snippets.