I want to get the current logged in user in a class-based view. I can do that by extracting the user from the request object, but how can I obtain that object?
class HomeView(TemplateView):
template_name='home.html'
def get_context_data(self, **kwargs):
context = super(HomeView, self).get_context_data(**kwargs)
context['username'] = request.user.username
return context
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With