Chapter 4. Models

In Chapter 2, Views and Urlconfs, we covered the fundamentals of building dynamic websites with Django: setting up views and URLconfs. As we explained, a view is responsible for doing some arbitrary logic, and then returning a response. In one of the examples, our arbitrary logic was to calculate the current date and time.

In modern web applications, the arbitrary logic often involves interacting with a database. Behind the scenes, a database-driven website connects to a database server, retrieves some data out of it, and displays that data on a web page. The site might also provide ways for site visitors to populate the database on their own.

Many complex websites provide some combination of the two. www.amazon.com, for instance, ...

Get Mastering Django: Core 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.