vendredi 16 octobre 2020

Django Template If does not work as expected

i'm trying to create a HTML drop-down with Django that shows the numbers 1 - 250 in the template and always selects the last selection after reloading the page. For this i use a variable "clea" to get the value with "request.GET.get('clea')" from the url in my "views.py" to pass it as context.

To select the value in the drop-dwon I have the following syntax:

        # Context: {"VIEW": {"clea": "140"}
        
        <label style="color: white;">Amount</label>
        <select class="browser-default" id="clea">

        
        
        <script>console.log("Finished")</script>

      </select>

Everything works except the If Statement from Django Template! In the log you can see that it always logs false, except if forloop.counter and data.VIEW.clea are equal, then its true, as expected. But it will never log "Worked", although it logs "true" in the line above. Does anyone know what this could be?

Aucun commentaire:

Enregistrer un commentaire