Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个没有views.py和models.py的现有项目。它有一个用户登录系统。我想获取模板中所有用户的列表。我搜索了更多但没有找到解决方案。
如果您出于某种原因不想要views.py,您可以创建自定义模板标签:
@register.simple_tag def user_list(): return '<br>'.join([str(u) for u in get_user_model().objects.all()])