We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
as the title
The text was updated successfully, but these errors were encountered:
I agree that this feels like a useful addition. Happy to support a PR if anyone has the time to work on this.
Sorry, something went wrong.
I gave it a quick try but was unable to create a user from the Web UI.
from sqlmodel import SQLModel, Field class User(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) name: str
import logging from flask import Flask, request, g from flask_admin import Admin from flask_admin.contrib.sqla import ModelView from flask_admin.theme import Bootstrap4Theme from flask_babel import Babel from sqlalchemy import create_engine from sqlmodel import SQLModel, Session from models import User app = Flask(__name__) app.config["SECRET_KEY"] = "secret" log = logging.getLogger('werkzeug') log.setLevel(logging.ERROR) def get_locale(): user = getattr(g, "user", None) if user is not None: return user.locale return request.accept_languages.best_match(["en"]) def get_timezone(): user = getattr(g, "user", None) if user is not None: return user.timezone babel = Babel(app, locale_selector=get_locale, timezone_selector=get_timezone) engine = create_engine("sqlite:///database.db", echo=True) session = Session(engine) admin = Admin(app, name="", theme=Bootstrap4Theme(swatch="simplex")) admin.add_view(ModelView(User, session)) @app.route("/") def index(): return "<a href=\"/admin/\">Click me to get to Admin!</a>" def create_db_and_tables(): SQLModel.metadata.create_all(engine) if __name__ == "__main__": create_db_and_tables() app.run()
No branches or pull requests
as the title
The text was updated successfully, but these errors were encountered: