3

URL Mapping, Views, and Templates

In the previous chapter, we were introduced to databases, and we learned how to store, retrieve, update, and delete records from a database. We also learned how to create Django models and apply database migrations.

However, these database operations alone cannot display an application’s data to a user. We need a way to display all the stored information in a meaningful way to the user – for example, displaying all the books present in our Bookr application’s database, in a browser, and in a presentable format. This is where Django views, templates, and URL mapping come into play. Views are the part of a Django application that takes in a web request and provides a web response. For example, a web request ...

Get Web Development with Django - Second Edition 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.