how to change input field size with flask-admin

After studying long hours both the documentation and the source codes of flask-admin and wtforms, I still could not understand how to vary the size of input fields in flask-admin model forms.​According to wtf "crash course" page, it should be possible to pass to the form fields css parameters in the templates, like this (jinja2 example):<form method="POST" action="/login"> <div>{{ form.username.label }}: {{ form.username(size="10") }}</div> <div>{{ form.password.label }}: {{ form.password() }}</div><...Read more

Flask admin roles adding roles_accapted to add_view

I have managed to get roles working with this code but!class Roled(object):def is_accessible(self): roles_accepted = getattr(self, 'roles_accepted', None) if flask_login.current_user.is_authenticated: user = CustomUser.objects.get(email=flask_login.current_user.id) for role in user.roles: for permission in role.permissions: if permission == "admin": return flask_login.current_user.is_authenticateddef inaccessible_callback(self, name, **kwargs): # redirect to login page if user ...Read more

how to use flask-admin for editing modelview

How to set password_hash using generate_password_hash from the edit page of flask-admini create a username and password in python shell. the password is hashingadmin.add_view(MyModelView(User, db.session) - let me edit the User class Modelswhen i edit the password and submit but the password is saved in plain text.How to edit password from flask-admin, the password should be save in hashing typeMy code is:from werkzeug.security import generate_password_hash, check_password_hashclass User(db.Model): id = db.Column(db.Integer, primary_key=Tru...Read more

Hide fields from ModelView in Flask-admin form_create

Is there a proper way of excluding fields from showing up in the create form of Flask-admin? I would normally do something like this in order to specify which fields to show on the create and edit form:class UserView(sqla.ModelView): form_create_rules = { 'username' } form_edit_rules = ('username', 'photos')Even though this works as expected, I get the following warning when running my application:UserWarning: Fields missing from ruleset: photos warnings.warn(text)Is there a better way of defining what fields to show on each form that do...Read more

Flask Admin doesn't show all fields

I have model like this:class User(db.Model): __tablename__ = 'users' __table_args__ = {'mysql_engine' : 'InnoDB', 'mysql_charset' : 'utf8'} id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) email = db.Column(db.String(120), unique=True) _password = db.Column('password', db.String(80)) def __init__(self, username = None, email = None, password = None): self.username = username self.email = email self._set_password(password) def _set_password(self, password):...Read more

How can I avoid Flask-Admin 2.1 warning "UserWarning: Fields missing from ruleset"?

I'm using Flask-Admin 2.1 with Python 2.7.6.One of my Flask-Admin model classes inherits from flask.ext.admin.contrib.sqla.ModelView and overrides form_rules.When I run my application, this warning is displayed: "UserWarning: Fields missing from ruleset"The warning is accurate: There are fields in my model that are not included in the ruleset. But that's by design. I don't want those fields to be displayed when users create or edit instances of this model.I have already read this: https://github.com/flask-admin/flask-admin/pull/815#issuecomment...Read more

Flask-admin: different create_form and edit_form with @property in model class

This is my goal: create_form: - new_file: FileUploadField which allows my users to upload files to my webserver edit_form: - new_file: FileUploadField which allows users to upload a new file to replace the existing file - current_file: anchor link to download the file or text which says "No file to download"I've decided to add a custom property to my model Instruction:class Instruction(DBModel): gdrive_id = db.Column(db.String(64)) @property def current_file(self): if self.gdrive_id: return Markup("<a href='%s'>Click h...Read more

Flask-Admin override default view with a ModelView class?

As described here you can override the the default view of Flask-Admin by declaring a child class of AdminIndexView and passing the view to the admin app. Is it possible to override the the default view with a ModelView class view? If so how would I go about doing that? I only really need ModelViews for my admin panel and can't figure out how to get rid of the default view. Thanks for the help....Read more

how to make a custom filter in flask admin

What am I doing wrong in this?? I am getting an exception thrown.Exception: Invalid field : does not contains any columns.I actually want to filter results from three different columns containing the cost of rooms.If any room satisfies a certain condition from the three rooms then it should appear on the list. That's why I want to make a custom filter.Please help me. Thanks in advance. from flask.ext.admin.babel import lazy_gettext from flask.ext.admin.model import filters class MyBaseFilter(filters.BaseFilter): """ B...Read more