Home > Articles > Open Source > Python

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

1.8 Putting It All Together

The chapter outlined the project to be built in Parts I, II, and III of the book and introduced Django.

Django is a Python web framework based on MVC architecture, which signifies that Django removes the tedium of building websites by supplying a universal, reusable codebase. This approach saves developers time in the long run but creates an overhead cost of having to learn the interdependent system. Like any framework, Django works on the principle of inversion of control, sometimes called the Hollywood principle (“Don’t call us, we’ll call you”), which explains why we write code in locations dictated by Django convention. Specifically, in keeping with MVC architecture, we know that we need only worry about the Models, Views, and Controllers and that Django will glue them together and handle everything else.

In this chapter, we used django-admin to generate the project scaffolding necessary for Django. This scaffolding allows us to add code in specific locations, according to inversion of control.

We not only generated a Django project but also created the apps necessary for any project: a project is a website, whereas an app is a feature, a piece of website functionality. The site we’ve set out to build is a startup categorization system paired with a blog. Given the two features, we created two apps using Django’s manage.py tool. We then used this tool to run a test server, checking our work. The test server informed us that, now that we have our apps created and connected to our project via settings.py, we should configure our site URLs. We take a quick look at this in the next chapter, but we wait until Chapter 5 before we really get there.

This book seeks to teach Django by example. Part I teaches Django’s core, or the pieces of the framework that are typically required for every project. Django organizes project data according to MVC theory. Chapters 3, 4, and 5 each demonstrate a core Django feature, each an aspect of MVC. In Chapter 3, we organize our data and create a database. In Chapter 4, we create the display output for our data. In Chapter 5, we connect our data to our display, creating webpages by programming Django views, pointed to by URL configurations.

Before we jump into MVC, however, Chapter 2: Hello World: Building a Basic Webpage in Django illustrates a basic Django site, which sheds light on the power of MVC.

  • + Share This
  • 🔖 Save To Your Account