Django 4 for the Impatient

Book description

A quick-start guide to exploring and using Python and Django to develop web applications in minutes

Key Features

  • Develop web applications with Python and Django quickly
  • Understand Django features with short explanations and learn how to use them right away
  • Create a movie reviews app with a responsive user interface and deploy it to the cloud

Book Description

Learning Django can be a tricky and time-consuming activity. There are hundreds of tutorials, loads of documentation, and many explanations that are hard to digest. However, this book enables you to use and learn Django in just a couple of days.

In this book, you’ll go on a fun, hands-on, and pragmatic journey to learn Django full stack development. You'll start building your first Django app within minutes. You'll be provided with short explanations and a practical approach that cover some of the most important Django features, such as Django Apps’ structure, URLs, views, templates, models, CSS inclusion, image storage, authentication and authorization, Django admin panel, and many more. You'll also use Django to develop a movies review app and deploy it to the internet.

By the end of this book, you'll be able to build and deploy your own Django web applications.

What you will learn

  • Understand and implement Django Apps' basic structure, including URLs, views, templates, and models
  • Add bootstrap to improve the aesthetics of the site
  • Create your own custom pages and have different URLs to route to them
  • Navigate between pages by adding a header bar to all pages
  • Work with databases and models
  • Explore the powerful built-in admin interface with Django
  • Use Django's powerful, built-in authentication system
  • Deploy your Django project on the internet for the world to use

Who this book is for

This book is for Python developers at any level of experience with Python programming who want to build full-stack Python web applications using Django. The book is for absolute Django beginners.

Table of contents

  1. Django 4 for the Impatient
  2. Contributors
  3. About the author
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  6. Chapter 1: Installing Python and Django
    1. Technical requirements
    2. Understanding the app we will be building
    3. Installing Python
    4. Installing Django
    5. Running the Django local web server
    6. Summary
  7. Chapter 2: Understanding the Project Structure and Creating Our First App
    1. Technical requirements
    2. Understanding the project structure
      1. The moviereviews folder
      2. manage.py
      3. db.sqlite3
    3. Creating our first app
    4. Summary
  8. Chapter 3: Managing Django URLs
    1. Technical requirements
    2. Understanding and defining Django URLs
      1. Creating a custom path for a home page
      2. Creating a custom path for an about page
    3. Summary
  9. Chapter 4: Generating HTML Pages with Templates
    1. Technical requirements
    2. Understanding Django templates
      1. Template
      2. View
      3. URLs
    3. Passing data into templates
    4. Adding Bootstrap to our site
    5. Adding a search form
    6. Sending a form to another page
      1. Creating a back link
    7. Summary
  10. Chapter 5: Working with Models
    1. Technical requirements
    2. Creating our first model
    3. Installing pillow
    4. Managing migrations
    5. Accessing the Django admin interface
    6. Configuring for images
    7. Serving the stored images
    8. Adding a movie model to admin
    9. Summary
  11. Chapter 6: Displaying Objects from Admin
    1. Technical requirements
    2. Listing movies
    3. Using the card component
    4. Implementing a search
    5. Adding a news app
      1. News model
    6. Listing news
    7. Summary
  12. Chapter 7: Understanding the Database
    1. Technical requirements
    2. Understanding the database viewer
    3. Displaying object information in admin
    4. Switching to a MySQL database
      1. Configuring the MySQL database
      2. Configuring our project to use the MySQL database
      3. Running the migrations
    5. Summary
  13. Chapter 8: Extending Base Templates
    1. Technical requirements
    2. Creating a base template
    3. Making the links work
    4. Adding a footer section
    5. Serving static files
    6. Summary
  14. Chapter 9: Creating a Movie Detail Page
    1. Technical requirements
    2. Creating a movie page
    3. Implementing links to individual movie pages
    4. Summary
  15. Chapter 10: Implementing User Signup and Login
    1. Technical requirements
    2. Creating a signup form
    3. Creating a user
    4. Handling user creation errors
      1. Checking whether passwords do not match
      2. Checking if a username already exists
    5. Customizing UserCreationForm
      1. Using UserCreateForm
    6. Showing whether a user is logged in
    7. Implementing the logout functionality
    8. Implementing the login functionality
    9. Summary
  16. Chapter 11: Letting Users Create, Read, Update, and Delete Movie Reviews
    1. Technical requirements
    2. Letting users post movie reviews
    3. Creating a review
    4. Listing reviews
    5. Updating a review
    6. Deleting a review
    7. Implementing authorization
    8. Summary
  17. Chapter 12: Deploying the Application to the Cloud
    1. Technical requirements
    2. Managing GitHub and Git
    3. Cloning our code on to PythonAnywhere
    4. Configuring virtual environments
    5. Setting up your web app
    6. Configuring static files
      1. Set DEBUG to False
      2. .gitignore
    7. Changing db.sqlite3 to MySQL or PostgresSQL
    8. Summary
    9. Why subscribe?
  18. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Django 4 for the Impatient
  • Author(s): Greg Lim, Daniel Correa
  • Release date: June 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803245836