Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I add search in flask-admin?
#1
I have a simple model.
class Words(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    russia = db.Column(db.String(50))
    english = db.Column(db.String(50))
    buttons = db.Column(db.Text())
    
    def __init__(self, russia=None, english=None, buttons=None):
        self.russia = russia
        self.english = english
        self.buttons = buttons

####### Admin ######### Admin ########## Admin ###########################
admin = Admin(app, name="Demo", template_mode='bootstrap3')
admin.add_view(ModelView(Words, db.session))
In Django this easy. Just add this
class SearchOnRussianWord(admin.ModelAdmin):
     search_fields = ('russia',)
How do I do it in flask-admin?
Quote
#2
Everything has appeared simply:

###### Models ######### Models ######## Models ###########
class Words(db.Model):
    __tablename__ = 'words'
    id = db.Column(db.Integer, primary_key = True)
    russia = db.Column(db.String(50))
    english = db.Column(db.String(50))
    buttons = db.Column(db.Text())
    
    def __init__(self, russia=None, english=None, buttons=None):
        self.russia = russia
        self.english = english
        self.buttons = buttons

class Mytools(ModelView):
    can_delete = False
    page_size = 50
    column_searchable_list = ['russia']
    
####### Admin ######### Admin ########## Admin ###########################
admin = Admin(app, name="Demo", template_mode='bootstrap3')
admin.add_view(Mytools(Words, db.session))
Quote
#3
Hi,
Thanks for the Answer.
I must appreciate you for providing such a valuable content for us.this is one amazing piece of article.Helped a lot in increasing my knowledge.
Quote
#4
Johnce ???
Quote
#5
Smells like a bot. It's only one post, so I don't think it's enough to call them a spammer.
micseydel likes this post
It's dangerous to go alone!  Take this: https://docs.python.org/3/library/index.html

Currently #4 in both post count, and rep. wavic and buran, I'm coming for you...
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Redirecting all Flask logs georgelza 0 38 Apr-18-2018, 12:48 PM
Last Post: georgelza
  Python /Flask Login with LDAP Auth pythonnubie 4 152 Apr-16-2018, 03:14 PM
Last Post: nilamo
  flask, I want to send a json from the front end and update it to the postgresql DB wi passion044 1 94 Apr-12-2018, 08:40 AM
Last Post: thomasp
  Flask - Opening second page via href is failing - This site can’t be reached rafiPython1 2 76 Apr-11-2018, 08:41 AM
Last Post: rafiPython1
  General advice web application - flask - database - cms bashage 6 396 Jan-31-2018, 06:07 PM
Last Post: frostbite
  python3 + Flask + SQLite = HTTP 400 supertoy 5 331 Jan-30-2018, 02:13 PM
Last Post: supertoy
  Uninitialized ASN.1 value in Flask LDAP3 Auth blueprint zoidberg 1 349 Nov-15-2017, 12:29 PM
Last Post: zoidberg
  show csv file in flask template.html rr28rizal 5 2,851 Nov-12-2017, 01:53 PM
Last Post: rr28rizal
  Insert data to SQL through pymysql and flask iainstott 3 827 Oct-24-2017, 03:04 PM
Last Post: iainstott
  How to install flask boostrap? Peter_EU 3 711 Oct-22-2017, 05:09 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)