Questions tagged [flask-admin]

Flask-Admin is an extension for the Flask framework. It can be used for building admin interfaces easily, with model scaffolding support for many existing python ORMs. Use this tag for questions related to this extension only, and not for general 'admin' functionalities in Flask.

Flask-Admin is an advanced, extensible and simple to use 'administrative interface building' extension for the Flask framework.

It comes with batteries included: model scaffolding for SQLAlchemy, MongoEngine, pymongo and Peewee ORMs, a simple file management interface and a lot of usage examples.

You are not limited by the default functionality - instead of providing simple scaffolding for the ORM models, Flask-Admin provides tools that can be used to construct administrative interfaces of any complexity, using a consistent look and feel.

Documentation: https://flask-admin.readthedocs.io/en/latest/

GitHub: https://github.com/flask-admin/flask-admin

Issue tracker: https://github.com/flask-admin/flask-admin/issues

692 questions
7
votes
3 answers

How can i both register blueprint and add that app to flask-admin

my Code: __init__.py from flask import Flask from flask_admin import Admin from flask_admin.contrib.sqla import ModelView from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config.from_object('config') db = SQLAlchemy(app) from…
Chan
  • 117
  • 2
  • 6
7
votes
2 answers

How do I properly set up flask-admin views with using an application factory?

I'm trying to setup flask-admin model views with SQLAlchemy against 'user' and 'role' models. Instead of a function admin view I'm getting: ValueError: Invalid model property name .desc Stack trace: Traceback (most recent…
gonzo
  • 135
  • 1
  • 10
7
votes
1 answer

exclude specific fields in flask-admin's create/edit forms

I have some fields in my models which I specifically want to exclude from my ModelView. Reference https://flask-admin.readthedocs.org/en/latest/api/mod_model/, I attempted to exclude those specific fields using form_exclude_columns, e.g. class…
Calvin Cheng
  • 35,640
  • 39
  • 116
  • 167
7
votes
2 answers

Flask-Admin customize datetime view

When using flask-admin, the list view for datetime fields is something like this: "2014-02-22 13:30:43". I'd like to know if is possible to change this default view for something like this: "2014-02-22" or "2014-02-22 13:30". thanks
user1943289
  • 91
  • 1
  • 4
7
votes
3 answers

How to reference a ModelView in flask-admin

What's the right way to get the URL for a flask-admin ModelView? Here's a very simple example: my_admin_view.py from flask.ext.admin.contrib.sqla import ModelView from common.flask_app import app from models import db, User, Role admin = Admin(app,…
tohster
  • 6,973
  • 5
  • 38
  • 55
7
votes
1 answer

Flask-Admin upload and insert in database automatically

My user is modeled in SQLAlchemy as: class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) url_pic = Column(String(50), nullable=False) (...) And I want to add the user to the database in Flask-Admin in…
gpestana
  • 365
  • 1
  • 6
  • 15
6
votes
1 answer

Flask SQLAlchemy: How to add a column that depends on another table?

I have three tables in my SQLAlchemy database (using Flask SQLAlchemy): Product, Product variation and Order. I want to see in an order, which product and its variation it includes. It works well with relationships/foreign keys, but the main…
sortas
  • 1,527
  • 3
  • 20
  • 29
6
votes
1 answer

Flask Admin: extra_js and url_for

I'm trying to load a script on a certain ModelView in my admin pages: class CustomView(ModelView): # Neither approach works here: # with current_app.app_context(), current_app.test_request_context(): extra_js = [url_for('static',…
AlxVallejo
  • 3,066
  • 6
  • 50
  • 74
6
votes
1 answer

ImportError: cannot import name 'db'

I am working on adding flask admin to a preexisting flask boiler plate project. I've been able to get the basic project working at https://github.com/kc1/flask-base (SCREENSHOT). I now need to add modelviews to add basic CRUD functionality. To do…
user1592380
  • 34,265
  • 92
  • 284
  • 515
6
votes
1 answer

how to export column with relationship in flask-admin

I have a problem in the export to csv the tables whose relationship with others, while in the 'simple' work well. I have to add some basis for export? For example, this is db.Model: class Categoria(db.Model): __tablename__ = 'categorie' id =…
Angelo Vit
  • 83
  • 8
6
votes
2 answers

Reducing size of columns in Flask-Admin

Is there a way to limit the size (length/width) of a ModelView column? I am using a WYSIWYG editor and this creates really long text, therefor making the column for the ModelView very long. Here is picture of what it looks like. Look on the right…
kstullich
  • 651
  • 1
  • 11
  • 27
6
votes
1 answer

Custom and sortable column in Flask-Admin

I'm using Flask-Admin and SQLAlchemy and struggle to create a custom, sortable field in the listview. I a User and a Photo model like this: class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) …
NeoID
  • 901
  • 1
  • 11
  • 29
6
votes
2 answers

Flask admin overrides password when user model is changed

I am currently diving into a flask project and try to use flask-admin for the first time. Everything is working fine so far, but one thing really bothers me: Whenever I edit my User model the users password gets overwritten. I am following the…
oneiro
  • 80
  • 1
  • 7
6
votes
3 answers

Change model representation in Flask-Admin without modifying model

I have a model with a __repr__ method, which is used for display in Flask-Admin. I want to display a different value, but don't want to change the model. I found this answer, but that still requires modifying the model. How can I specify a…
peoff
  • 103
  • 1
  • 7
6
votes
2 answers

How to add content to the index page using Flask-Admin

I am using flask-admin, and I want to add a dashboard to the home page. I found I can add a new page using: admin = Admin(name='Dashboard', base_template='admin/my_master.html', template_mode='bootstrap3') then: admin.init_app(app) and finally I…
nycynik
  • 7,371
  • 8
  • 62
  • 87