39👍
Try this:
{% if myList|length and myValue == 'somestring' %}
blah blah
{% endif %}
Refer django documentation about use of boolean-operators and complex-expressions in django templates.
18👍
Should be something like this:
{% if myList|length and myValue == 'somestring' %}
blah blah
{% endif %}
2👍
Django docs on boolean operators
Should be something like this
- view.py
def posts_request(request):
message=ApplyPost.objects.filter( blah blah)
if message:
return render (request,'blah.html',{'message':message})
- blah.html
{% if message %}
{% for post in message %}
{% if post.provider %}
....
{% endif %}
{% if post.accept == True and post.provider %}
...
...
{% endif %}
....You can add multiple if,elif, with Operators ....
{% endfor %}
{% if message %}
and
{% if a == b or c == d and e %}
Be aware that and has a higher order of precedence than or, and that parentheses are not possible. If required use nested blocks
- Django: Access request object from admin's form.clean()
- Mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
- How to have a nested inline formset within a form in Django?
- How do I rebuild my django-mptt tree?
0👍
I think you might have to separate the if
and the ifequal
in two statements:
{% if myList|length %}
{% ifequal myValue 'somestring' %}
blah blah
{% endifequal %}
{% endif %}
Source:stackexchange.com