[Django]-Django template tag on built-in login User.objects.all()

4👍

url(r'^login/$', auth_views.login, {'extra_context':{'all_user':User.objects.all()}}, name='login'),

use like this

0👍

You must have get all user in views on django like

views.py

class GetUser():
      def get_context_data():
          all_user = ....(get data from api for model database)
          context = {(
             'all_user': all_user,
          )}
          return context

html will be

{% for user in all_user %}
   <option>{{ user.first_name }}</option>
{% endfor %}
👤Viktor

Leave a comment