For each of my 12 views I have a few commun querysets currently duplicated in each view. I'm wondering If there is a way to cache the result to avoid recalculating everytime (querysets are differents for each user but once it's set it's barely never change)
Company_user = Company.objects.get(User = request.user)
User_info = User_info.objects.get(User = request.user)
Groups_user = request.user.groups.values_list('name',flat = True)
Sales_company = Sales.objects.filter(Company = Company_user)
I have also few forms repeted in each views (bootstrap modal open by clicking in a navbar button)
- Change Password
- Change personal infos
- Change sales target
Change personnal informations Change target
Is there a way to optimize this ?
question from:
https://stackoverflow.com/questions/65830089/django-caching-queryset-result 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…