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
HackerRank seems neat: https://www.hackerrank.com/nilamo
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Flask Issues iainstott 12 1,033 Oct-29-2016, 06:07 PM
Last Post: iainstott
  unable to call function in Flask verb 5 475 Sep-29-2016, 02:27 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)