Django şablonlama sisteminde bir değişkeni nasıl atayabilirim?Django: Şablonda değişken atamak
{% restaurant_id as restaurant.id %}
veya {{ restaurant_id as restaurant.id }}
çalışmıyor: Restaurant
varsayarsak
bir modelidir.
Django şablonlama sisteminde bir değişkeni nasıl atayabilirim?Django: Şablonda değişken atamak
{% restaurant_id as restaurant.id %}
veya {{ restaurant_id as restaurant.id }}
çalışmıyor: Restaurant
varsayarsak
bir modelidir.
Sen with template tag kullanın ve böyle bir iç şablon değişkenini atamak olabilir:
{% with restaurant_id=restaurant.id %}
... use restaurant_id in this template section ...
{% endwith %}
Not: filtrelerden yararlanabilirsiniz şablon etiketi "ile":
foo is {{ foo }}
{% with bar=foo|slice'6:9' %}
bar is {{ bar }}
{% endwith %}