Is it possible to change web2py view on the fly?

Can you change the view used by web2py in the controller? Ideally, I would be interested in doing something like:

response.view = 'NewViewName'

+4
source share
1 answer

This is accurate for you, although be sure to specify the relative path to the view in the / views folder. So, if you have / views / default / other _view.html, you can do:

response.view = 'default/other_view.html' 

You can also directly visualize any view:

 def myfunc(): context = dict(...) return response.render('default/other_view.html', context) 

See here and here .

+8
source

Source: https://habr.com/ru/post/1389556/


All Articles