Установлена авторизация пользователя для входа на сайт- все работает.
Установлено приложение flask-admin - тоже по адресу site/admin работает, базу данных показывает.
Хочу связать авторизацию и flask-admin.
app/__init__.py:
from flask import Flask, current_app
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from config import Config
from flask_admin import Admin
from flask_bcrypt import Bcrypt
db = SQLAlchemy()
migrate = Migrate()
login = LoginManager()
login.login_view = 'auth.login'
admin = Admin(name='My Admin Panel', template_mode='bootstrap4')
bcrypt = Bcrypt()
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
db.init_app(app)
migrate.init_app(app, db)
login.init_app(app)
admin.init_app(app)
from app.main import bp as main_bp
app.register_blueprint(main_bp)
from app.auth import bp as auth_bp
app.register_blueprint(auth_bp, url_prefix='/auth')
from app.index import bp as index_bp
app.register_blueprint(index_bp)
return app
from app import models
app/index/routes.py:
GNU nano 6.2 app/index/routes.py from flask_login import login_required
from app.index import bp
from flask import render_template
from flask_admin import Admin
from app import admin
@bp.route('/admin')
@login_required
def base():
return admin
Ошибка:
File "/var/www/project_flask/app/index/routes.py", line 11, in base
return admin
TypeError: 'Admin' object is not callable