python - <flask web 開發>項目permission問題
問題描述
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’`
我已經添加permission進數據庫了,為什么程序還是提示這個問題? 有沒有已經完成flasky這個項目的前輩。指導一下唄,謝謝
問題解答
回答1:self.role為None,flasky完整項目https://github.com/miguelgrin...可以參考
相關文章:
1. 注冊賬戶文字不能左右分離2. html - vue項目中用到了elementUI問題3. 對mysql某個字段監控的功能4. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能5. JavaScript事件6. python - 使用readlines()方法讀取文件內容后,再用for循環遍歷文件與變量匹配時出現疑難?7. showpassword里的this 是什么意思?代表哪個元素8. html5 - ElementUI table中el-table-column怎么設置百分比顯示。9. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。10. javascript - ES6標準入門中let命令提到的for循環打印i是10,如果不用let怎么替換?
