我有这个错误:
未定义全局名称“用户”
我做错了什么以及如何纠正它?
context_processors.py
from content.models import *
from django.contrib.auth.models import User
def your_earned(request):
if request.user.is_authenticated():
ecredit = UserEarned.objects.get(user=user)
if ecredit.exists():
return {'ecredit': ecredit}
else:
ecredit = '0'
return {'ecredit':ecredit}
else:
pass