4

Can you change the view being used by web2py in the controller? Ideally I'd be interested in doing something like:

response.view = 'NewViewName'

Chris
  • 5,876
  • 3
  • 43
  • 69

1 Answers1

8

You've got it exactly, though be sure to include the relative path to the view within 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 render any view:

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

See here and here.

Anthony
  • 25,466
  • 3
  • 28
  • 57