Skip to content

Instantly share code, notes, and snippets.

@oduvan
Created March 7, 2024 10:58
Show Gist options
  • Save oduvan/00cd64b98f3479192b033eb23cf240f8 to your computer and use it in GitHub Desktop.
Save oduvan/00cd64b98f3479192b033eb23cf240f8 to your computer and use it in GitHub Desktop.
from functools import cached_property
class DataProxy:
def __init__(self, user):
self.user = user
@cached_property
def plan(self):
return DBModel.objects.get(id=67)
@cached_property
def price_3d(self):
return DBModelItem.objects.get(plan=self.plan, id=67)
def context_manager(request):
return {"DATA": DataProxy(request.user)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment