how do I replace no username with a string of choice in Django

删除回忆录丶 提交于 2019-12-02 10:51:18

You can use for...empty

It doesn't make much sense to include it in a model so you can just provide a default if the thing being iterated over in the for loop is empty

{% for user in ticket.assigned.all %}
     {{ user.email }}{% if not forloop.last %},{% endif %}
{% empty %}
  No user assigned 
{% endfor %}

The advantage here is you could always use the empty section to insert a button into your table to allow people to be assigned (for example).

Try use {{ user }} instead {{ user.email }}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!