About Caching Property Values
You can cache model properties with functools.cached_property
decorator:
from functools import cached_property
from django.contrib.auth.models import AbstractUser
def User(AbstractUser):
@cached_property
def is_editor(self):
return self.groups.filter(name="Editors").exists()
Tips and Tricks Programming Django 5.x Django 4.2 Django 3.2 Python 3
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent app
For Django websites that use cookies.
Django App for You