1👍
✅
Assuming the “user” in your template is a django.contrib.auth.User
instance, the simplest solution to add a is_client()
method to User
is to monkeypatch User
:
# youmodels.py
from django.contrib.auth.models import User
# your models here...
def user_is_client(user):
try:
client = user.client
except Client.DoesNotExist:
return False
else:
return True
User.is_client = user_is_client
But as schneck commented, it might be better to have a custom User model if your django version is recent enough.
Source:stackexchange.com