flask-admin

Flask-admin; To add custom logic during row insertion

这一生的挚爱 提交于 2020-01-25 21:13:42
问题 I'm new to the flask-admin library so please forgive me if this is trivial. When I click 'Save' to create a new row for a model, I also want to do some custom things. In my case, I'll create a table dynamically whose name is the string entered in the form. This will be in addition to what flask-admin does for me i.e. add a new row to the model table. So where will I put the custom logic to do what I want to do? I saw this post on so: Customize (override) Flask-Admin's Submit method from edit

Flask-admin; To add custom logic during row insertion

爱⌒轻易说出口 提交于 2020-01-25 21:13:11
问题 I'm new to the flask-admin library so please forgive me if this is trivial. When I click 'Save' to create a new row for a model, I also want to do some custom things. In my case, I'll create a table dynamically whose name is the string entered in the form. This will be in addition to what flask-admin does for me i.e. add a new row to the model table. So where will I put the custom logic to do what I want to do? I saw this post on so: Customize (override) Flask-Admin's Submit method from edit

Creating one-to-one relationship Flask-SQLAlchemy

泪湿孤枕 提交于 2020-01-24 12:57:45
问题 I am trying to create a one-to-one relationship between a Department & Ticket table. This way when looking inside of Flask-Admin a user would be able to see the Department name instead of the ID. I have tried to setup the relationship as follows: # Ticket Table class Tickets(db.Model): __tablename__ = 'tickets' ticketID = db.Column(db.Integer, nullable=False, primary_key=True, autoincrement=True, unique=True) cust_name = db.Column(db.String(50), nullable=False) cust_email = db.Column(db

Display first element of a one-to-many relationship in Flask-Admin

淺唱寂寞╮ 提交于 2020-01-23 16:13:05
问题 I'm currently using Flask-Admin to create an admin screen but I'm running into a roadblock. Suppose I have two classes that look like this: class Part(db.Model): id = db.Column(db.Integer, primary_key=True, unique=True) part_data = db.relationship("PartHistory", backref="part") name = db.Column(db.String(255)) class PartHistory(db.Model): id = db.Column(db.Integer, primary_key=True, unique=True) part_id = db.Column(db.Integer, db.ForeignKey('part.id')) date_checked = db.Column(db.Date) Part

Display first element of a one-to-many relationship in Flask-Admin

好久不见. 提交于 2020-01-23 16:12:27
问题 I'm currently using Flask-Admin to create an admin screen but I'm running into a roadblock. Suppose I have two classes that look like this: class Part(db.Model): id = db.Column(db.Integer, primary_key=True, unique=True) part_data = db.relationship("PartHistory", backref="part") name = db.Column(db.String(255)) class PartHistory(db.Model): id = db.Column(db.Integer, primary_key=True, unique=True) part_id = db.Column(db.Integer, db.ForeignKey('part.id')) date_checked = db.Column(db.Date) Part

flask security separating access data on flask admin

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-16 18:18:08
问题 i have an aplication homestay reservation built with flask.. every homestay have an user login, this login built with flask-security and every owner of the homestay have role User . and every user can input their homestay data with flask-admin. but unfortunately if a user input their data, the others user which have role User can seing the data have input too.. so.. my question how to separate the data if a user have the same role..? user A can just see his data, and user B so too.. this is

Flask Admin - performance difficulties

送分小仙女□ 提交于 2020-01-16 03:25:07
问题 I am facing to performance problem in Flask-Admin, although performance of Flask application is good. my model is: class Ck(Base): __tablename__ = "ck" id = Column(Integer, primary_key=True, autoincrement=True) nazev = Column(String(100)) kontakt = Column(Text) terms = relationship(Term, backref=backref('ck', lazy='noload'), lazy='dynamic') class Term(Base): __tablename__ = "term" id = Column(Integer, primary_key=True, autoincrement=True) hotel_id = Column(Integer, ForeignKey('hotel.id')) ck

Flask-admin inline modelling passing form arguments throws AttributeError

强颜欢笑 提交于 2020-01-15 04:11:27
问题 Hi there fellow Flask developers! In Flask-admin, I currently try to implement inline model editing into my model view. On the model side, I have a simple tree structure that represents a set of content pages. Each node has several child nodes and also several content data models associated with it. The models are named ContentNode and ContentData . If I use the inline_models property on the node view class as described in the Docs here, it seems to work fine at first. # AuthModelView is

flask-admin is_accessible usage

假装没事ソ 提交于 2020-01-11 09:50:12
问题 I've checked the docs and It's pretty vague how the is_accessible method should be implemented. Here is what the docs of flask admin showed class MicroBlogModelView(sqla.ModelView): def is_accessible(self): return login.current_user.is_authenticated() def inaccessible_callback(self, name, **kwargs): # redirect to login page if user doesn't have access return redirect(url_for('login', next=request.url)) what I don't get though is how do you call it is it automatically called or do you have to

Use flask admin to set config parameters

感情迁移 提交于 2020-01-07 09:33:21
问题 As title says, I have small web app, without using database and models. I'd like interface to change some of Flask own config parameters, and thought that flask-admin may bring me there quickly. Is this easily possible? 回答1: You can't generally change configuration after starting the application without restarting the server. The application (at least in production) will be served with multiple processes, possibly even on multiple servers. Changes to the configuration will only effect the