Why Work with this Book?
This book will save you time. On many occasions we’ve seen clever students get stuck, spending hours trying to fight with Django and other aspects of web development. More often than not, the problem was usually because a key piece of information was not provided, or something was not made clear. While the occasional blip might set you back 10-15 minutes, sometimes they can take hours to resolve. We’ve tried to remove as many of these hurdles as possible. This will mean you can get on with developing your application, and not have to sit there scratching your head.
This book will lower the learning curve. Web application frameworks can save you a lot of hassle and a lot of time. Well, that is if you know how to use them in the first place! Often the learning curve is steep. This book tries to get you going – and going fast. By showing you how to put together a web application with all the bells and whistle from the onset, the book shortens the learning curve.
This book will improve your workflow. Using web application frameworks requires you to pick up and run with a particular design pattern – so you only have to fill in certain pieces in certain places. After working with many students, we heard lots of complaints about using web application frameworks – specifically about how they take control away from them (i.e. inversion of control). To help you, we’ve created a number of workflows to focus your development process so that you can regain that sense of control and build your web application in a disciplined manner.
This book is not designed to be read. Whatever you do, do not read this book! It is a hands-on guide to building web
applications in Django. Reading is not doing. To increase the value you gain from this experience, go through and develop the application. When you code up the application, do not just cut and paste the code. Type it in, think about what it does, then read the explanations we have provided to describe what is going on. If you still do not understand, then check out the Django documentation, go to Stack Overflow or other helpful websites and fill in this gap in your knowledge. If you think it is worth mentioning, please get in touch with us so that we can improve the book – we already have a number of contributors and we will happily acknowledge your contribution!
What You Will Learn
In this book, we will be taking an example-based approach (or inquiry-based learning). The book will show you how to design a web application called Rango (see the Design Brief in Section 1.4.1 below). Along the way, we’ll show you how to perform the following tasks.
Setup a development environment – including how to use the terminal, the Pip installer, how to work with Git,
• Setup a Django project and create a basic Django application.
• Configure the Django project to serve static media and other media files.
• Work with Django’s Model-View-Template design pattern.
• Create database models and use the object-relational mapping functionality provided by Django.
• Create forms that can utilize your database models to create dynamically generated web pages.
• Use the User Authentication services provided by Django.
• Incorporate external services into the application.
• Design and apply CSS to improve the look and feel the web application.
• Work with cookies and sessions with Django.
• Include more advanced functionality like AJAX into your application.
• Deploy your application to a web server using PythonAnywhere.
At the end of each chapter, we have included a number of exercises designed to push you harder and to see if you can apply what you have learned. The later chapters of the book provide a number of open development exercises along with coded solutions and explanations.