Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Web Development with Django
Web Development with Django

Web Development with Django: Learn to build modern web applications with a Python-based framework

Arrow left icon
Profile Icon Ben Shaw Profile Icon Saurabh Badhwar Profile Icon Bird Profile Icon Bharath Chandra K S Profile Icon Chris Guest +1 more Show less
Arrow right icon
€8.99 €41.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (36 Ratings)
eBook Feb 2021 826 pages 1st Edition
eBook
€8.99 €41.99
Paperback
€52.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Ben Shaw Profile Icon Saurabh Badhwar Profile Icon Bird Profile Icon Bharath Chandra K S Profile Icon Chris Guest +1 more Show less
Arrow right icon
€8.99 €41.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (36 Ratings)
eBook Feb 2021 826 pages 1st Edition
eBook
€8.99 €41.99
Paperback
€52.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €41.99
Paperback
€52.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Web Development with Django

2. Models and Migrations

Overview

This chapter introduces you to the concept of databases and their importance in building web applications. You will start by creating a database using an open-source database visualization tool called SQLite DB Browser. You will then perform some basic Create Read Update Delete (CRUD) database operations using SQL commands. Then, you will learn about Django's Object Relational Mapping (ORM), using which your application can interact and seamlessly work with a relational database using simple Python code, eliminating the need to run complex SQL queries. You will learn about models and migrations, which are a part of Django's ORM, that are used to propagate database schematic changes from the application to the database, and also perform database CRUD operations. Toward the end of the chapter, you will study the various types of database relationships and use that knowledge to perform queries across related records.

Introduction

Data is at the core of most web applications. Unless we're talking about a very simple application such as a calculator, in most cases we need to store data, process it, and display it to the user on a page. Since most operations in user-facing web applications involve data, there is a need to store data in places that are secure, easily accessible, and readily available. This is where databases come in handy. Imagine a library operational before the advent of computers. The librarian would have to maintain records of book inventories, records of book lending, returns from students, and so on. All of these would have been maintained in physical records. The librarian, while carrying out their day-to-day activities, would modify these records for each operation, for example, when lending a book to someone or when the book was returned.

Today, we have databases to help us with such administrative tasks. A database looks like a spreadsheet or an Excel sheet containing records, with each table consisting of multiple rows and columns. An application can have many such tables. Here is an example table of a book inventory in a library:

Figure 2.1: Table of a book inventory for a library

Figure 2.1: Table of a book inventory for a library

In the preceding table, we can see that there are columns with details about various attributes of the books in the library, while the rows contain entries for each book. To manage a library, there can be many such tables working together as a system. For example, along with an inventory, we may have other tables such as student information, book lending records, and so on. Databases are built with the same logic, where software applications can easily manage data.

In the previous chapter, we had a brief introduction to Django and its use in developing web applications. Then we learned about the Model-View-Template (MVT) concept. Later, we created a Django project and started the Django development server. We also had a brief discussion about Django's views, URLs, and templates.

In this chapter, we will start by learning about the types of databases and a few basic database operations using SQL. After that, we will move on to the concept of models and migrations in Django, which assist in faster development by providing a layer of abstraction to facilitate database operations using Python objects.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Understand Django functionality and the Model-View-Template (MVT) paradigm
  • Create and iteratively build a book review website, adding features as you build your knowledge
  • Explore advanced concepts such as REST API implementation and third-party module integration

Description

Do you want to develop reliable and secure applications which stand out from the crowd, rather than spending hours on boilerplate code? Then the Django framework is where you should begin. Often referred to as a 'batteries included' web development framework, Django comes with all the core features needed to build a standalone application. Web Development with Django takes this philosophy and equips you with the knowledge and confidence to build real-world applications using Python. Starting with the essential concepts of Django, you'll cover its major features by building a website called Bookr – a repository for book reviews. This end-to-end case study is split into a series of bitesize projects that are presented as exercises and activities, allowing you to challenge yourself in an enjoyable and attainable way. As you progress, you'll learn various practical skills, including how to serve static files to add CSS, JavaScript, and images to your application, how to implement forms to accept user input, and how to manage sessions to ensure a reliable user experience. Throughout this book, you'll cover key daily tasks that are part of the development cycle of a real-world web application. By the end of this book, you'll have the skills and confidence to creatively tackle your own ambitious projects with Django.

Who is this book for?

Web Development with Django is designed for programmers who want to gain web development skills with the Django framework. To fully understand the concepts explained in this book, you must have basic knowledge of Python programming, as well as familiarity with JavaScript, HTML, and CSS.

What you will learn

  • Create a new application and add models to describe your data
  • Use views and templates to control behavior and appearance
  • Implement access control through authentication and permissions
  • Develop practical web forms to add features such as file uploads
  • Develop a RESTful API and JavaScript code that communicates with it
  • Connect to a database such as PostgreSQL

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 25, 2021
Length: 826 pages
Edition : 1st
Language : English
ISBN-13 : 9781839213779
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Feb 25, 2021
Length: 826 pages
Edition : 1st
Language : English
ISBN-13 : 9781839213779
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 130.97
Web Development with Django
€52.99
Learn Python Programming, 3rd edition
€35.99
Django 3 By Example
€41.99
Total 130.97 Stars icon
Banner background image

Table of Contents

16 Chapters
1. Introduction to Django Chevron down icon Chevron up icon
2. Models and Migrations Chevron down icon Chevron up icon
3. URL Mapping, Views, and Templates Chevron down icon Chevron up icon
4. Introduction to Django Admin Chevron down icon Chevron up icon
5. Serving Static Files Chevron down icon Chevron up icon
6. Forms Chevron down icon Chevron up icon
7. Advanced Form Validation and Model Forms Chevron down icon Chevron up icon
8. Media Serving and File Uploads Chevron down icon Chevron up icon
9. Sessions and Authentication Chevron down icon Chevron up icon
10. Advanced Django Admin and Customizations Chevron down icon Chevron up icon
11. Advanced Templating and Class-Based Views Chevron down icon Chevron up icon
12. Building a REST API Chevron down icon Chevron up icon
13. Generating CSV, PDF, and Other Binary Files Chevron down icon Chevron up icon
14. Testing Chevron down icon Chevron up icon
15. Django Third-Party Libraries Chevron down icon Chevron up icon
16. Using a Frontend JavaScript Library with Django Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(36 Ratings)
5 star 66.7%
4 star 19.4%
3 star 5.6%
2 star 8.3%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Cris LaFortune Apr 12, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A beginner-friendly introduction to Django. The book walks you through creating databases in Django from start to finish.
Amazon Verified review Amazon
Jonathan Reeves Jun 23, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you are looking to build applications with Python and Django look no further than this book. It is a one stop shop for learning the best practices that are current and modern for developing Django based web apps. I was looking for something that would help me take my Django building skills into 2021 and this book did that. It breaks down the concepts very easily and covers a lot of topics. I highly recommend the title if you are a Python developer looking to build web apps.
Amazon Verified review Amazon
marco pineda May 24, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book for any Django newcomer looking for a deep dive
Amazon Verified review Amazon
Manish Kumar Jul 24, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This might be the best book written about Django for beginners. It builds a simple web application called "Bookr" for displaying book reviews. And the nice thing about this book is that it gradually introduces new concepts as the web app is fleshed out. It gives you just the right amount of detail for each topic and never bogs you down with unnecessary and obscure knowledge. Highly recommended.
Amazon Verified review Amazon
Sujit Packiaraj Oct 28, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is easy to read and understand which is rare for a thick programming book. The authors go through each step of building an example web app in high detail. I found Chapter 8 (Media Serving and File Upload), Chapter 12 (REST API's and Token-Based Authentication), and Chapter 14 (Testing) to be especially helpful, containing information I can't easily find online. Overall, I'm glad to have this book as a reference.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.