At 15 years old, the Django web framework is arguably the most popular Python web framework today and one of the most successful open source Python projects ever. Many things and people have contributed to this, and one of them is the architecture of the framework. Django sites, or projects, are made up of several to many "apps," packages that may include everything from database models to forms and HTTP views required to support one particular part of the project. Not only do apps help organize larger web projects, they also make it possible to reuse that functionality by reusing apps across other projects as their own installable Python packages: Django standalone apps.
This book is for Django developers who are either new to writing their own standalone apps or who have written them before but are looking for some common guidance. You don’t need to be a Django guru-ninja-wizard-whatever to write standalone apps, but you will need at least moderate familiarity with Django to use this book.
This book is for developers in two categories:
• You have been working with Django for at least a little while and would like to create a standalone app.
• You have written at least one Django standalone app already but there are aspects of creating another or managing your app, from process to corner cases, that you’re unsure of.
The book is roughly grouped into four parts.
The first part is geared toward the developer who has not yet written a standalone app and maybe who finds the idea of putting together, and publishing, a Python package a bit daunting (it’s not!). What we’ll cover in this part is designed to be enough to get you started with a basic but working and publishable standalone app. In the first eight chapters, you'll learn how to structure a standalone app, manage features like templates and migrations, and create a separate installable package.
The second part is a little bit more strategic. Here we’re concerned with the concepts around pulling standalone apps out from existing projects. In this situation you seemingly have an advantage since you already have working code written; however, if you want to extract for reuse, you have to identify where to draw the line between likelycoupled code in your own project. More challenging is the prospect of not just making a reusable app based on your code, but replacing your original code with your new standalone app. This part deals with those questions, decisions, and some strategies for these real-world situations.
The third part carries forward the topics in Part 1 including how to work through further issues. How do you best deal with app-specific configuration? How can you support multiple versions of Django or Python? Some of the topics here overlap with issues you’ll face in any Django project; however, the details of implementing them, and implementing them well in a standalone app, pose different challenges. This is when you’ll need to start considering scenarios beyond your own immediate use case, those things you haven’t yet had to worry about in your own projects. If the goal of creating a reusable app is to streamline and simplify the process of building Django websites, then here we want to streamline and simplify the process of building and maintaining reusable apps themselves.
The fourth part is about managing a Django standalone app in the wild. How do you ensure you have a good release every time? What’s the best way of ensuring a Django version–compatible pipeline? While there is overlap here with managing any software package, Python or otherwise, we’ll focus especially on issues and solutions to Django apps.