亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Django錯誤:TypeError at / 'bool' object is not callable解決

 更新時間:2019年08月16日 11:18:35   作者:希希里之海  
這篇文章主要介紹了Django 錯誤:TypeError at / 'bool' object is not callable解決,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

使用 Django自帶的 auth 用戶驗證功能,編寫函數(shù),使用 is_authenticated 檢查用戶是否登錄,結(jié)果報錯:

TypeError at / 'bool' object is not callable  

編寫函數(shù)如下:

def index(request, pid=None, del_pass=None):
  if request.user.is_authenticated():
    username = request.user.username
    useremail = request.user.email
  messages.get_messages(request)
  template = get_template('index.html')
  html = template.render(context=locals(), request=request)
  return HttpResponse(html)

查詢相關(guān)資料,發(fā)現(xiàn) is_authenticated 是屬性而不是方法,我們應(yīng)該把括號去掉,這樣就沒什么問題了。

將 

if request.user.is_authenticated():

改為

 if request.user.is_authenticated:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論