`
喜欢蓝色的我
  • 浏览: 371188 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

django 报错“int() argument must be a string or a number, not 'SimpleLazyObject'”

 
阅读更多

                                                         django登录页面报错

报错信息“int() argument must be a string or a number, not 'SimpleLazyObject'”

修改代码: Change user=request.user to user=request.user.id:

原来代码:

def home(request):
    tests = TestCase.objects.filter(user=request.user)

    user_counts = TestCase.objects.filter(user=request.user).count()
    #user_scripts = TestCase.objects.filter()
return TemplateResponse(request, 'home.html', {"tests": tests ,"user_counts":user_counts })

修改为:

def home(request):
    tests = TestCase.objects.filter(user=request.user.id)
    user_counts = TestCase.objects.filter(user=request.user.id).count()
    #user_scripts = TestCase.objects.filter()
return TemplateResponse(request, 'home.html', {"tests": tests ,"user_counts":user_counts })

 参考页面:http://stackoverflow.com/questions/20534577/int-argument-must-be-a-string-or-a-number-not-simplelazyobject

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics