from localauth.mixins import LoginRequiredMixin, UserPassesTestMixin class PartnerProfileRequiredMixin(LoginRequiredMixin, UserPassesTestMixin): def test_func(self): try: assert self.request.user.partnerprofile return True except: return False