我有一个现有的项目,没有views.py和models.py。它有一个用户登录系统。我想获取模板中所有用户的列表。我搜索了更多但没有找到解决方案。
If you for some reason don't want views.py, you can create custom template tag:
@register.simple_tag
def user_list():
return '<br>'.join([str(u) for u in get_user_model().objects.all()])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.