from django.contrib.auth.decorators import user_passes_test def is_chef(user): try: profile = user.profile return profile.is_chef except: return False chef_required = user_passes_test(lambda u: is_chef(u)) def is_ernesto(user): try: profile = user.profile return profile.is_ernesto except: return False ernesto_required = user_passes_test(lambda u: is_ernesto(u))