July 2019
Beginner to intermediate
302 pages
9h 38m
English
To create a simple admin interface, perform the following steps:
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 ...