Chapter 2. Stateless Web Application
Most Django applications and tutorials center on some variety of user-generated content, such as to-do lists, blogs, and content management systems. This isn’t surprising given Django’s original roots in journalism.
In 2005, Django was originally developed at World Online in Lawrence, Kansas, as a way for reporters to quickly create content for the Web. Since then, it has been used by publishing organizations such as the Washington Post, the Guardian, PolitiFact, and the Onion. This aspect of Django may give the impression that its main purpose is content publishing, or that Django itself is a content management system. With large organizations such as NASA adopting Django as their framework of choice, however, Django has obviously outgrown its original purpose.
In the previous chapter we created a minimal project that made use only of Django’s core HTTP handling and URL routing. In this chapter we will expand upon that example to create a stateless web application that uses more of Django’s utilities, such as input validation, caching, and templates.
Why Stateless?
HTTP itself is a stateless protocol, meaning each request that comes to the server is independent of the previous request. If a particular state is needed, it has to be added at the application layer. Frameworks like Django use cookies and other mechanisms to tie together requests made by the same client.
Along with a persistent session store on the server, the application can then handle ...
Get Lightweight Django 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.