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
  General advice web application - flask - database - cms bashage 6 265 Jan-31-2018, 06:07 PM
Last Post: frostbite
  python3 + Flask + SQLite = HTTP 400 supertoy 5 171 Jan-30-2018, 02:13 PM
Last Post: supertoy
  Uninitialized ASN.1 value in Flask LDAP3 Auth blueprint zoidberg 1 246 Nov-15-2017, 12:29 PM
Last Post: zoidberg
  show csv file in flask template.html rr28rizal 5 1,509 Nov-12-2017, 01:53 PM
Last Post: rr28rizal
  Insert data to SQL through pymysql and flask iainstott 3 510 Oct-24-2017, 03:04 PM
Last Post: iainstott
  How to install flask boostrap? Peter_EU 3 361 Oct-22-2017, 05:09 PM
Last Post: Larz60+
  (beginner): Hello Shopping - wat?(Flask) Peter_EU 2 322 Oct-20-2017, 07:32 PM
Last Post: Peter_EU
  starting with flask: code does not work Peter_EU 2 270 Oct-20-2017, 05:35 PM
Last Post: Peter_EU
  Flask Flash Messages Blank Leaf 2 330 Oct-16-2017, 10:19 PM
Last Post: Leaf
  how to place Flask code on a public web server rarevesselt 6 849 Oct-04-2017, 07:32 AM
Last Post: rarevesselt

Forum Jump:


Users browsing this thread: 1 Guest(s)