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
Kevin Flynn is my spirit animal.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Uninitialized ASN.1 value in Flask LDAP3 Auth blueprint zoidberg 1 59 Nov-15-2017, 12:29 PM
Last Post: zoidberg
  show csv file in flask template.html rr28rizal 5 205 Nov-12-2017, 01:53 PM
Last Post: rr28rizal
  Insert data to SQL through pymysql and flask iainstott 3 109 Oct-24-2017, 03:04 PM
Last Post: iainstott
  How to install flask boostrap? Peter_EU 3 110 Oct-22-2017, 05:09 PM
Last Post: Larz60+
  (beginner): Hello Shopping - wat?(Flask) Peter_EU 2 126 Oct-20-2017, 07:32 PM
Last Post: Peter_EU
  starting with flask: code does not work Peter_EU 2 132 Oct-20-2017, 05:35 PM
Last Post: Peter_EU
  Flask Flash Messages Blank Leaf 2 106 Oct-16-2017, 10:19 PM
Last Post: Leaf
  how to place Flask code on a public web server rarevesselt 6 462 Oct-04-2017, 07:32 AM
Last Post: rarevesselt
  Tornado / Flask help needed jogl 2 207 Aug-27-2017, 10:21 PM
Last Post: jogl
  Insert data in a table after a user is created from djando admin prithvi 0 177 Aug-11-2017, 06:25 PM
Last Post: prithvi

Forum Jump:


Users browsing this thread: 1 Guest(s)