2👍
✅
try with the below view function
class UsersView(TemplateView):
template_name = 'customer/users/users.html'
def get_context_data(self,**kwargs):
context = super(UsersView,self).get_context_data(**kwargs)
context['object_list'] = CustomUser.objects.all()
return context
0👍
I don’t understand how this code could ever have worked. Your view is a simple template view, and never does anything to get a list of users: that applies as much to the default User model as to your custom one.
You need to subclass ListView instead of TemplateView, and set the model
attribute to your User class.
- [Django]-"Failed to establish a new connection" when trying to access Elasticsearch Cloud with elasticsearch-dsl Python package
- [Django]-Using Python 3.7 on Pycharm gives me: "Error: Django is not importable in this environment"
Source:stackexchange.com