Creating our first view
Now that we have created our URL and interpreted by the routing system, we must ensure that a view (which is a controller in the MVC pattern) meets the customer's demand.
This is the function of the second parameter of the URLs present in urls.py
. This parameter will define the method that will play the role of a view. Take, for example, our first URL:
url (r'^$', 'TasksManager.views.index.page'),
Firstly, as we have seen when studying regular expressions, this URL will be valid only if we browse the http://localhost:8000
URL. The second parameter in the URL means that in the index.py
file, there is a method called page
that will process the request. The index.py
file is located in the views
package at the root of the
Get Django: Web Development with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.