Answer the question
In order to leave comments, you need to log in
How to add a variable to a class?
hello
there is a class
class RestoreView(FlaskView):
restore =True
error = ''
form = RestorePwdForm()
def get(self):
return render_template('login.html', form =self.form, restore=self.restore, error =self.error)
def post(self):
print(request.form)
if request.form:
try:
a= resetpwd(request.form['email'])
print(a)
self.error = 'Ваш новый пароль {0}'.format(a)
except:
self.error ="ИДИ ОТСЮДА"
return redirect(url_for('RestoreView:get'))
Answer the question
In order to leave comments, you need to log in
transfer form = RestorePwdForm() to the def get method, the error tells you working outside of application context that you are creating an object outside the context.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question