Django template conditional variable assignment

前端 未结 3 1020
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 21:31

I want to assign a variable do different values depending on if a variable exists, is this possible? My non working example might make it clearer:

{% if user         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 22:02

    Create a template tag that takes username and recent_users as arguments which then outputs the menu. That way you will keep your template clean from that kind of logic.

提交回复
热议问题