[Answer]-Django filter field on the context processor

1👍

You can use the {% if %} template tag. So:

{% if model.field == 2 %}
# do something
{% endif %}

Here is the official documentation:

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#operator

Edit:

If model.field has a value of 2 then it just needs to be the above.

Edit 2:

Without seeing your code, it is hard to tell, but here is how to filter for Users based on Gender in a template:

{% for user in users %}
  {% if user.gender == "male" %}
    # do something
    user.username
  {% endif %}
{% endfor %}

Leave a comment