I want to display all the users, in my template but I cannot. I think there is a mistake in my codes but I cannot find it. Here is codes.
views.py
class UsersView(TemplateView): template_name = 'users.html' def get_context_data(self, **kwargs): context = super(UsersView, self).get_context_data(**kwargs) context['object_list'] = UserList.objects.all() return context models.py
class UserList(AbstractBaseUser): first_name = models.CharField(max_length=200, blank=True, help_text="The first name of the user.") last_name = models.CharField(max_length=200, blank=True, help_text="The last name of the user.") email = models.EmailField( verbose_name='email address', max_length=255, unique=True, help_text="The email and username of the user. Required." ) users.html
{% extends 'blog/base.html' %} {% block content %} <h1>Users:</h1> <ul> {% for users in object_list %} <li class="user">{{ user }}</li> {% endfor %} </ul> {% endblock %} And this is the page that I get:
Where is my mistake? Thank you.
UserList. Normally Django models are named in a singular way, here you "hint" that an object is in fact a list ofUsers.django.contrib.auth.models.Usermodel you are after, the default model used for authentication.