oTree Forum >

Unparsable expression error when running the code locally but not on Heroku

#1 by Elifb (edited )

Hello, 

I am re-running an old code which used to work fine, but now it gives an error when I run it locally (using devserver). The code still works fine when I run it through Heroku. Can anyone help me why I get this error? I am sharing the code and the error below.


Code:
<div class="center" style="padding:1%">
  {{ if player.timedout == 0 && player.pmt == "Fixed" }} 
  <p style="border: none; padding:1%; text-align: center;"> Payment rule: <span style="color: blue">Fixed Payment</span> </p> 
  {{ elif player.timedout == 1 && player.pmt == "Fixed" }}
  <p style="border: none; padding:1%; text-align: center;"> You timed out and were randomly assigned to <span style="color: blue">Fixed Payment</span> rule. </p> 
  {{ elif player.timedout == 0 }}
  <p style="border: none; padding:1%; text-align: center;"> Payment rule: <span style="color: blue">Competitive Payment</span> </p> 
  {{ else }}
  <p style="border: none; padding:1%; text-align: center;"> You timed out and were randomly assigned to <span style="color: blue">Competitive Payment</span> rule. </p> 
  {{ endif }}
  </div>
  
  
  Error:
  TemplateSyntaxError: Unparsable expression '0 && player.pmt == "Fixed"' (line 364, in "if")

#2 by coralio , (edited )

Have you tried "and" instead of "&&" ?
The language used in Django templates is not Javascript.
Hope this helps.

#3 by Elifb

That was it, thanks a lot! 

It's so weird that it works in the older Heroku version. It gave the same error when I re-uploaded to a new Heroku server. But anyways, this fixes it. Thanks again.

Write a reply

Set forum username