2013-02-19 8 views

答えて

0

私は二つの文でififequalを分離する必要があるかもしれないと思う:

{% if myList|length and myValue == 'somestring' %} 
    blah blah 
{% endif %} 

{% if myList|length and myValue == 'somestring' %} 
    blah blah 
{% endif %} 
12

はこのようなものであるべきboolean-operatorsの使用については、djangoのマニュアルを参照してください。 djangoテンプレートのcomplex-expressions

+0

あなたと同じです。私はパーティーに遅刻していると思う。 – arulmr

+0

@arulmr 2分遅れだが1票先に:) – kmerenkov

+0

ごめんなさい。その偶然の一致。 – arulmr

15

はこれを試してみてください:

{% if myList|length %} 
    {% ifequal myValue 'somestring' %} 
      blah blah 
    {% endifequal %} 
{% endif %} 
0

Django docs on boolean operators

Should be something like this

  1. view.py
def posts_request(request): 
    message=ApplyPost.objects.filter(blah blah) 
    if message: 
     return render (request,'blah.html',{'message':message}) 
  1. 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 %} 

それと比べて優先度の高い順位を持っているか、および括弧が不可能であることに注意してください。必要に応じてネストされたブロックを使用する

関連する問題