FAQ Database Discussion Community


how can i register a Flask-Admin BaseView as a module

python,flask,flask-admin
How can I register a Flask-Admin BaseView as a module in my application? every time I run my app I get a blueprint collision error! I also know about ModelView in Flask-Admin, but I want to separate models and views from each other. init.py from flask import Flask import flask_admin...

Tyring to set up modelview with Flask-Admin causes ImportError

python,flask,flask-sqlalchemy,flask-admin
I am trying to add a User model view to Flask-Admin. However, I get ImportError: cannot import name db. Why is this happening and how do I fix it? app/__init__.py: from flask import Flask from flask_sqlalchemy import SQLAlchemy import flask_admin as admin from app.models import User db = SQLAlchemy() admin...

how to use flask-admin for editing modelview

flask-admin
How to set password_hash using generate_password_hash from the edit page of flask-admin i create a username and password in python shell. the password is hashing admin.add_view(MyModelView(User, db.session) - let me edit the User class Models when i edit the password and submit but the password is saved in plain text....

Cannot remove last field from input in panel

mongodb,flask,mongoengine,flask-admin,flask-mongoengine
In Flask panel I have class which inherits embedded document and I have inside persons = db.ListField(db.ReferenceField('Person', required=False, null=True), default=[], required=False) When I want to remove last Person from my input field via Flask Admin Panel it saves document but do not remove, when I have two I can remove...

How to enforce constraints in `flask-admin`?

python,flask,flask-sqlalchemy,flask-admin
We're using http://flask-admin.readthedocs.org/ for a quick admin interface. Our model has constraints defined as follows: __table_args__ = ( db.UniqueConstraint(user_id, role, domain_id), db.UniqueConstraint(user_id, role, customer_id), ) When saving a record that violates a constraint while in debug mode, the app stops with a traceback. If not in debug mode, it reports...

How to specify label_attr for a model in a Flask-Admin ModelView using MongoEngine?

python,mongoengine,flask-admin
I think I have a pretty common use case and am surprised at how much trouble it's giving me. I want to use a key-value pair for a ReferenceField in the Flask-Admin edit form generated by the following two classes: class Communique(db.Document): users = db.ListField(db.ReferenceField(User), default=[]) class User(db.Document): email =...

Why does url_for() works with 'static' as first parameter? There's no static()

python,flask,flask-admin,url-for
Can't understand why it does work, so I can't change it: I'm using Flask-Admin's ImageUploadField in a form, the field is this: image = ImageUploadField(label='Optional image', base_path=app.config['UPLOAD_FOLDER'], relative_path=op.relpath(app.config['UPLOAD_FOLDER']), endpoint='static' ) endpoint='static' is the default value. endpoint is used in flask_admin.ext.form.upload this way: def get_url(self, field): if field.thumbnail_size: filename = field.thumbnail_fn(field.data)...

Flask-admin separate view for models filtered by foreign key

python,flask,sqlalchemy,flask-sqlalchemy,flask-admin
I have two sql-alchemy classes. One is Quiz and another one is Reply: class Quiz(db.Model): id = db.Column(db.Integer, primary_key=True) quiz_question = db.Column(db.Text) quiz_date = db.Column(db.DateTime) replies = db.relationship("Reply") class Reply(db.Model): id = db.Column(db.Integer, primary_key=True) reply_text = db.Column(db.Text) reply_date = db.Column(db.DateTime) reply_mark = db.Column(db.Integer) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) quiz_id = db.Column(db.Integer,...

Flask-Admin vs Flask-AppBuilder

python,flask,flask-admin
I am new to Flask and have noticed that there are two plugins that enable CRUD views and authorized login, Flask-Admin and Flask-AppBuilder. These two features interest me along with nice Master-Detail views for my model, where I can see both the rows of the master table and the relevant...

Flask: Connecting models to files, e.g. profile pictures [closed]

database-design,flask,flask-sqlalchemy,flask-admin,flask-security
If it matters, I use Flask-Security, Flask-SQLAlchemy and Flask-Admin in my application. How should I design my application so that I can connect a row in the database with one or more files, e.g. a user to their profile pictures?...

Editing Files With Flask-Admin

flask,flask-admin
I am using Flask-Admin to provide an admin interface for my web app, and so far everything has gone well. However, I am trying to make it so that the .TXT files can be edited right in the browser. Reading the docs, I have incorporated the line: editable_extensions = ('txt')...