How to add, multiply number variables in a Django template?

前端 未结 5 1935
死守一世寂寞
死守一世寂寞 2020-12-28 19:36

The JS snippet I created relies on the forloop.counter variable being available within a {% for key, value in data.items %}..{% endfor %} tag.

Is there

5条回答
  •  情话喂你
    2020-12-28 20:11

    I make the next in my template file carts.html

    {% extends 'base.html'%} {% block contenido %}
    

    Checkout

    Subtotal + IVA: ${{ orden.sub_total }}

    Envio:$ {{ orden.costo_envio }}

    Total a pagar:$ {{ orden.sub_total|add:orden.costo_envio }}

    {% endblock %}

    where my view based function is:

    def carrito_checkout(request):
        if 'cart_id' in request.session:
            orden_object, created = Orden.objects.get_or_new(request)
            if orden_object is None:
                return redirect('carrito:home')
            print(orden_object)
            context = {
                "orden": orden_object
            }
    
        return render(request, 'carrito_checkout.html', context=context)
    

    For me this aproach works fine

提交回复
热议问题