title: Django- How to use two UserPassesTestMixin
body: <p><strong>Using Multiple UserPassesTestMixin Works for other views but not for the <code>ProfileCreateView</code></strong></p>
  
  <p>There seems to be a logic error which i am not able to figure out!</p>
  
  <p>views.py</p>
  
  <pre><code>class CurrentUser(UserPassesTestMixin):
      def test_func(self):
          x = self.request.user.slug
          print (x)
          y = self.kwargs['slug']
          print (y)
          if x == y:
              return True
          else:
              if self.request.user.is_authenticated():
                  def get_absolute_url(self):
                      return reverse('profile:view_profile', kwargs={ "slug": self.slug })
  
  
  class ProfileCreate(CurrentUser, UserPassesTestMixin, LoginRequiredMixin, UpdateView):
      model = User
      form_class = ProfileForm
      template_name="profile/profile_new.html"
  
      def test_func(self):
          x = self.get_object().full_name
          print (x)
          y = ''
          if x == y:
              return True    
          else:
              def get_absolute_url(self):
                  return reverse('profile:view_profile', kwargs={ "slug": self.slug })
  
  
  
  class ProfileEdit(CurrentUser, UserPassesTestMixin, LoginRequiredMixin, UpdateView):
      model = User
      form_class = ProfileForm
      template_name="profile/profile_new.html"
  
      def test_func(self):
          x = self.get_object().full_name
          #print (x)
          y = ''
          if x != y:
              return True
          else:
              def get_absolute_url(self):
                  return reverse('profile:profile_edit', kwargs={ "slug": self.slug })
  </code></pre>
  
  <p>The class <code>CurrentUser</code> checks if the user has the permission to edit a profile. A user will only be able to edit the profile if he is the author of the profile. Both the x and y is this class prints different values <strong>x prints the slug value of the loggedin user</strong> whereas <strong>y prints the slug from the url</strong> how can this be true?</p>
  
  <p>The <code>test_func</code> in the <code>ProfileCreate</code> class checks if the user has already created a profile ie., if the <code>full_name</code> is an empty string, then it allows the user to create profile. else redirects to other view.</p>
  
  <p>The <code>CurrentUser</code> class works fine for other views such as <code>ProfileEdit</code>, etc.,</p>
  
  <p><strong>Summary!</strong>-- 
  loggedin user-  <code>localhost:8000/username1</code></p>
  
  <p>the user will be able to access <code>localhost:8000/username1/edit/</code> but not <code>localhost:8000/username2/edit/</code></p>
  
  <p>the user will be able to access <code>localhost:8000/username1/create/</code> only if the <code>full_name</code> is empty.
  If the user is loggedin as username1, then the user should not be able to access <code>localhost:8000/username2/create/</code>---- This part of the code does not work. what is the logic error in the code?</p>