Я пытаюсь проверить маршрут редактирования для своей фляги. Приложение. Но получите эту ошибку. Я думаю, что эта ошибка обычно из-за возврата, хотя у меня есть возврат на моем пути редактирования, как я могу исправить эта ошибка Спасибо? ошибка:ValueError: функция просмотра не ответила
File "/home/peg/flask-Alembic/test/test_app.py", line 59, in test_monkey_edit
response = self.client.get('/edit/1', follow_redirects=True)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/test.py", line 762, in get
return self.open(*args, **kw)
response = self.run_wsgi_app(environ, buffered=buffered)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/test.py", line 855, in run_wsgi_app
app_iter = app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1478, in full_dispatch_request
response = self.make_response(rv)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1566, in make_response
raise ValueError('View function did not return a response')
ValueError: View function did not return a response
view.py:
@layout.route('/edit/<int:id>', methods=['GET','POST'])
def edit(id=None):
user = Users.query.get_or_404(id)
form = LoginForm(obj=user)
if request.method=='POST':
if form.validate_on_submit()== True:
form.populate_obj(user)
db.session.commit()
flash("You have been updated the profile")
return redirect(url_for('layout.user',page=1,sortby='normal'))
else: #If the form does not have all fields that are required
return render_template('edit.html', form=form, id=id)
test.py:
def test_edit(self):
u = Users(name='user1', email='[email protected]', age=25)
db.session.add(u)
db.session.commit()
data = dict(name='admin', email='[email protected]', age=28)
db.session.commit()
response = self.client.get('/edit/1', follow_redirects=True)
self.assertTrue('You have been edit the profile', response.data)
возможно дубликат http://stackoverflow.com/questions/26852969/valueerror-view-function-did-not -return-a-response-in-flask –
Возможный дубликат функции [Функция просмотра не возвращала ответа] (http://stackoverflow.com/questions/14770098/view-function-did-not-return-a-response) – dirn