To create a simple admin interface, perform the following steps:
- Start with the models by adding a new BooleanField field called admin to the User model in auth/models.py. This field will help in identifying whether the user is an admin or not:
from wtforms import BooleanField class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(60)) pwdhash = db.Column(db.String()) admin = db.Column(db.Boolean()) def __init__(self, username, password, admin=False): self.username = username self.pwdhash = generate_password_hash(password) self.admin = admin def is_admin(self): return self.admin
The preceding method simply returns the value of the admin field. This can have a custom implementation ...