我正在使用內置的django登錄。我如何使用標籤在其模板上顯示註冊用戶的所有名字?內置登錄的Django模板標籤User.objects.all()
有沒有功能來添加一個背景,因爲它是內置所以 這是我加入到我的urls.py,則kwargs件事是什麼我讀其他職位。
from django.contrib.auth.models import User
url(r'^login/$', auth_views.login, name='login', kwargs={'all_user': User.objects.all()}),
我在登記模板/ login.html的默認
{% for user in all_user %}
<option>{{ user.first_name }}</option>
{% endfor %}
當我現在訪問它返回一個錯誤的登錄:
LoginView() received an invalid keyword 'all_user'. as_view only accepts arguments that are already attributes of the class.
有沒有一種方式,我可以將上下文置於內置登錄?
可使用你需要[在django-logout-b中添加額外的上下文uilt-in-view](https://stackoverflow.com/questions/6757062/adding-extra-context-in-django-logout-built-in-view) –