python - <flask web 開(kāi)發(fā)>項(xiàng)目permission問(wèn)題
問(wèn)題描述
AttributeError: ’NoneType’ object has no attribute ’permission’---------------------------------------------------------------` {% if current_user.can(Permission.MODERATE_COMMENTS) %}
File '/home/centos/Desktop/workspace/flasky_163/app/models.py', line 207, in can def generate_email_change_token(self, new_email, expiration=3600):s = Serializer(current_app.config[’SECRET_KEY’], expiration)return s.dumps({’change_email’: self.id, ’new_email’: new_email}) def can(self, permission):return (self.role.permission & permission) == permission def is_administrator(self):return self.can(Permission.ADMINISTER) def ping(self):AttributeError: ’NoneType’ object has no attribute ’permission’`
我已經(jīng)添加permission進(jìn)數(shù)據(jù)庫(kù)了,為什么程序還是提示這個(gè)問(wèn)題? 有沒(méi)有已經(jīng)完成flasky這個(gè)項(xiàng)目的前輩。指導(dǎo)一下唄,謝謝
問(wèn)題解答
回答1:self.role為None,flasky完整項(xiàng)目https://github.com/miguelgrin...可以參考
相關(guān)文章:
1. mysql - AttributeError: ’module’ object has no attribute ’MatchType’2. javascript - JS設(shè)置Video視頻對(duì)象的currentTime時(shí)出現(xiàn)了問(wèn)題,IE,Edge,火狐,都可以設(shè)置,反而chrom卻...3. javascript - 圖片能在網(wǎng)站顯示,但控制臺(tái)仍舊報(bào)錯(cuò)403 (Forbidden)4. MySQL客戶(hù)端吃掉了SQL注解?5. 網(wǎng)頁(yè)爬蟲(chóng) - python爬蟲(chóng)翻頁(yè)問(wèn)題,請(qǐng)問(wèn)各位大神我這段代碼怎樣翻頁(yè),還有價(jià)格要登陸后才能看到,應(yīng)該怎么解決6. 數(shù)據(jù)庫(kù) - MySQL 單表500W+數(shù)據(jù),查詢(xún)超時(shí),如何優(yōu)化呢?7. objective-c - iOS怎么實(shí)現(xiàn)像QQ或者微信的實(shí)時(shí)推送8. php自學(xué)從哪里開(kāi)始?9. 求大神幫我看看是哪里寫(xiě)錯(cuò)了 感謝細(xì)心解答10. phpstady在win10上運(yùn)行
