通过命令行执行 创建superuser 账户
@manager.option(‘-n‘, ‘-name‘, dest="name") @manager.option(‘-p‘, ‘-password‘, dest="password") def createsuperuser(name, password): if not all([name, password]): print("参数不足") user = User() user.nick_name = name user.mobile = name user.password = password user.is_admin = True try: db.session.add(user) db.session.commit() except Exception as e: db.session.rollback() print(e) print("添加成功")
使用方法:命令行执行 python manager.py creatsuperuser -n admin -p qqq123...A
原文地址:https://www.cnblogs.com/oscarli/p/12305396.html
时间: 2024-11-10 14:27:17