Home  >  Q&A  >  body text

python - <flask web development> project permission issues

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'`


I have added permission into the database, why does the program still prompt this question? Is there anyone who has completed the flasky project? Please give me some guidance, thank you

天蓬老师天蓬老师2686 days ago660

reply all(1)I'll reply

  • 某草草

    某草草2017-06-12 09:26:08

    self.role is None, flasky complete project https://github.com/miguelgrin... can be referred to

    reply
    0
  • Cancelreply