Class Based View to get user authentication in Django
I dont know whats the context of your ClassBasedView ... but you can use the LoginRequiredMixin to require the login before calling your class :
class ServerDeleteView(LoginRequiredMixin, DeleteView):
    model = Server
    success_url = reverse_lazy('ui:dashboard')
Ok, have a class based view that passes a query_set into my AssignedToMe class. The point of this class based view is to see if a user is logged in and if they are, they can go to a page and it will display all of records that are assigned to their ID. Currently, it is working how I want it to but only if a user is logged in. If a user is not logged in, I get the following error 'AnonymousUser' object is not iterable.
I want it to redirect the user to the login page if there is no user logged in. Thank you in advance. Please look at the screenshot