+ 1
how to add sweet alert in flask?
i try to add sweet alert using flashing message it is not working well so i try to add sweet alert using js sweet alert is working well but data is not saving else error message will display for all possibilities. i i'm confused now how to add sweet alert using js or flask flashing methods? help me please
19 Answers
+ 1
k i'll try it
0
i try is already on error message is working data is not saving so posted question here
0
maybe try posting what error message are you getting.
0
if request.method == 'POST':
country = request.form.get('country') #getting form data
admin_instance = Country() #mysql data is stored in separate python file and this is the instance of that
account = admin_instance.get_country_by_name(country) #compare if the entered already
if account:
flash("Already exits",'error') #if country already exist then display error
return redirect('/AddCountry')
else:
flash("Successfully Submitted", 'success') #else success
add_country = admin_instance.add_country(country, date_now) #saving data to mysql
i got only error as message for every input and data is not saving to mysql i have written comments( #) as that u can understand above code is flask
0
I am confused.
are you using js comments '//' in a .py python file? shouldn't those '//' supposed to be '#' instead?
0
sorry yes it have return wrong right now i have edited please help me
0
are you sure your db is running, properly initiated and accessible?
0
yes working perfectly i just separated mysql and route files ,it working
0
what's the error message you're getting?
0
sweet alert not working i have written sweetalert.html and flash("Already exits",'error')
0
is your sweetalert cdn valid? did you set up the template properly?
0
yes same as given in this github code https://github.com/ondiekelijah/SweetAlert-Js-with-Flask
0
did you clone the repo or typed it manually? perhaps you have a typo...
it's hard to say, blind-guessing this way...
0
typed it manually
0
recheck the sweetalert parts. flask is not finding it. Did you use the template method or inline method? maybe your filepath is wrong
0
How to work on it like pro
0
How can I add a background image in html