我正在为我的系统做一些计算,我需要得到一个
superuser
像这样
location = LocationData.objects.filter(email=self.request.user.email).count()
,
然后我需要计算该用户的所有许可证,就像这样
count = MyUser.objects.filter(location_count=self.request.user.email).count()
,
我需要检查一下
location
==
count
以及
*
有价格的地点,
if count == location:
context['social'] = location * FRISTPRICE
当我得到价格,我需要显示在模板上。
完整的视图是
class AdminDashboard(TemplateView):
"""
"""
template_name = 'administration/admin.html'
@cached_property
def get_context_data(self, **kwargs):
context = super(AdminDashboard, self).get_context_data(**kwargs)
user = MyUser.objects.get(pk=self.request.user.pk)
if user.is_superuser:
location = LocationData.objects.filter(email=self.request.user.email).count()
count = MyUser.objects.filter(location_count=self.request.user.email).count()
if count == location:
context['first_package'] = location * FIRSTPRICE
if count == location:
context['second_package'] = location * SECONDPRICE
if count == location:
context['third_package'] = location * THIRDPRICE
return context
完全错误是
HERE
,我的第一个猜测是上下文不能返回,并且这个计算不好,所以可以有人帮助我理解为什么我会得到这个错误,谢谢。