March 2018
Beginner to intermediate
336 pages
8h 22m
English
Now that we have gone through the basics, let's work on our Todo Task list. We want to have a /todos URL showing us a web page with a list of Todo Tasks.
For that, we need a controller method to prepare the data to present, and a QWeb template to present it to the user.
Edit the todo_website/controllers/main.py file to add this method:
#class Todo(http.Controller):
#...
@http.route('/todos', auth='user', website=True)
def index(self, **kwargs):
TodoTask = request.env['todo.task']
tasks = TodoTask.search([])
return request.render(
'todo_website.index', {'tasks': tasks})
The controller retrieves the data to be used and makes it available to the rendered template. In this case, the controller requires an authenticated ...
Read now
Unlock full access