[Answered ]-How does the 'as' reserved word work in Django Template Language?

2👍

Assignment tags allow you to store the result of a template tag in a variable. The get_cart tag that you linked to is an assignment tag.

After running

{% get_cart as cart  %}

You can then access the result of the get_cart tag in the {{ cart }} variable.

Note that not all Django template tags support the as keyword. Assignment tags are deprecated, in Django 1.9+ you can use the as keyword with simple tags.

Leave a comment