Skip to content

Instantly share code, notes, and snippets.

@killthekitten
Last active November 18, 2019 14:54
Show Gist options
  • Save killthekitten/e9c2549a22bd8a372c2164781a9d524d to your computer and use it in GitHub Desktop.
Save killthekitten/e9c2549a22bd8a372c2164781a9d524d to your computer and use it in GitHub Desktop.
Showcase of a Flask-Admin 1.5.4 regression

Showcase of a Flask-Admin 1.5.4 regression

The sample code throws an error in Flask-Admin 1.5.3 when creating a user through the UI, but doesn't throw it in 1.5.4

More details you can find in the issue.

Before running, prepare the environment:

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
flask run

And migrate the db in flask shell:

from app import db

db.create_all()
from flask import Flask
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
app.config['SECRET_KEY'] = 'test'
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
def __init__(self, *args, **kwargs):
raise RuntimeError("Raise me!")
def __repr__(self):
return '<User %r>' % self.username
admin = Admin(app, name='microblog', template_mode='bootstrap3')
# Add administrative views here
admin.add_view(ModelView(User, db.session))
app.run()
Flask==1.1.1
Flask-Admin==1.5.4
Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment