from django.views.generic import View
from django.shortcuts import render


class MemberProfileView(View):
    template_name = 'accounts/profile.html'

    def get(self, request):
        return render(request, self.template_name)
from django.views.generic import View
from django.shortcuts import render
from django.contrib.auth.mixins import LoginRequiredMixin


class MemberProfileView(LoginRequiredMixin, View):
    login_url = '/accounts/login/'
    redirect_field_name = 'redirect_to'
    template_name = 'accounts/profile.html'

    def get(self, request):
        return render(request, self.template_name)

Add login required mixin to user profile
Add login required mixin to user profile

  from django.views.generic import View
  from django.shortcuts import render
+ from django.contrib.auth.mixins import LoginRequiredMixin
  
  
- class MemberProfileView(View):
+ class MemberProfileView(LoginRequiredMixin, View):
+     login_url = '/accounts/login/'
+     redirect_field_name = 'redirect_to'
      template_name = 'accounts/profile.html'
  
      def get(self, request):
          return render(request, self.template_name)
+ 
Add login required mixin to user profile
## Code Before:
from django.views.generic import View
from django.shortcuts import render


class MemberProfileView(View):
    template_name = 'accounts/profile.html'

    def get(self, request):
        return render(request, self.template_name)
## Instruction:
Add login required mixin to user profile
## Code After:
from django.views.generic import View
from django.shortcuts import render
from django.contrib.auth.mixins import LoginRequiredMixin


class MemberProfileView(LoginRequiredMixin, View):
    login_url = '/accounts/login/'
    redirect_field_name = 'redirect_to'
    template_name = 'accounts/profile.html'

    def get(self, request):
        return render(request, self.template_name)
