2017-02-25 7 views
-1

アサーションエラー/ accounts/tcresults 例外メッセージはありません。 私は、このエラーが起こる理由を私は理解できないviews.pyAssertionError/accounts/tcresults

def tc(request): 
    tcresults = ImageAndUser.objects.filter(user=request.user).order_by('id').last() 
    d = { 
     'tcresults': tcresults, 
    } 
    return render(request, 'registration/accounts/tc.html', d) 

でtc.html

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Score</title> 
</head> 
<body> 
    <h1>Score</h1> 
    <h2>Your Score is 
     {{ tcresults.tc }} 
     {{ value1 = tcresults.tc 
     if value1 > 5000: 
       <h2>Good</h2> 
      elseif value1 < 900: 
      <h2>Bad</h2> 
     }} 

    </h2> 
</body> 
</html> 

に書いています。 これを解決するにはどうすればよいですか?あなたのHTML内

答えて

0

、あなたが実行する必要があります。{% %}は、フロー制御に使用されている間

<h2>Your score is {{ tcresults.tc }}</h2> 
{% if tcresults.tc > 5000 %} 
    <h2>Good</h2> 
{% elif tcresults.tc < 900 %} 
    <h2>Bad</h2> 
{% endif %} 

{{ }}は、変数を評価するために使用されています。

+0

thx、ur comments。私はurコードを書いたが、「Your Score is」の数は空白になりました。私は何をすべきですか? – user7523656

+0

良い、悪いもそこに表示されていません。 – user7523656

+0

thx !!あなたのスコアの一部は〜ですが、if文(Good&Badを含む)は表示されません。これを修正するにはどうすればよいですか? – user7523656