flask sqlalchemy with dropdown list

by: Agilyolchuyev, 8 years ago


Hi guys.
First of thank you for reading my post. I am new in flask world. So if question is silly sorry for this. I need to write smole bootstrap and flask combine application. The idea is basic I will great admin page and each time when new user will add, administrator should determine group of that user (by default it will be viewer). Now I have two 2 questions first can someone please write how can I keep default value in sqlalchemy. My second how can I update table base on dropdown list parameter . If someone can share own experience I will be grateful Thank you for reading my post.



You must be logged in to post. Please login or register an account.



hi there,

it's better practice to keep default value on form submitting. i'd recomment wtforms and flask-wtforms if you are not using it. this module helps you protect your forms from csrf and other mallicious staff better. Also you can pick default value while you are defining form class. You call look up documentation from http://wtforms.readthedocs.io/en/latest/fields.html#the-field-base-class

for your second question you have 2 option. fist one is to write a basic js code for dropdown list to update page if you change the item and query new table parameters. by this way you have to refresh whole page but js code will be 1 or 2 lines. second way is to write jquery/ajax code to request new table content like prior option, then clear table and then create new one with new data. by this way only table part of the page refreshes (because its the idea behind js) and you page seem mode responsive and clear. but you have to write better and more complex js code. make your choice



-CarnageTR 8 years ago

You must be logged in to post. Please login or register an account.