Reader small image

You're reading from  Django in Production

Product typeBook
Published inApr 2024
Reading LevelIntermediate
PublisherPackt
ISBN-139781804610480
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Arghya Saha
Arghya Saha
author image
Arghya Saha

Arghya (argo) Saha, is a software developer with 8+ years of experience and has been working with Django since 2015. Apart from Django, he is proficient in JavaScript, ReactJS, Node.js, Postgres, AWS, and several other technologies. He has worked with multiple start-ups, such as Postman and HealthifyMe, among others, to build applications at scale. He currently works at Abnormal Security as a senior Site Reliability Engineer to explore his passion in the infrastructure domain. In his spare time, he writes tech blogs. He is also an adventurous person who has done multiple Himalayan treks and is an endurance athlete with multiple marathons and triathlons under his belt.
Read more about Arghya Saha

Right arrow

Preface

Hey there! As the name suggests, Django in Production is a book to help developers put their application code into production. In today’s world, coding has become a profession that people get into after joining a 3–6 month boot camp. With the start-up boom, most of these developers are able to land a job after their boot camp course, since they are able to write code and hack any product together. However, a couple of months into the job, they want to learn about the best practices and understand all the aspects that senior developers in the industry know and perform, but most start-ups don’t have many senior developers due to budget and talent scarcity. This book is going to give them a too long; didn’t read (TLDR) version of software development best practices, which they need to know to get to the next level.

Who this book is for

This book is for any software developer who understands the basic concepts of Django but now needs some help putting their code to production using the right tools, or someone who does not have enough guidance to know how to do the work the right way. We are assuming you have a basic understanding of how to write code in Django and now want to improve your skills.

What this book covers

Chapter 1, Setting Up Django with DRF, covers the basic project setup of Django and Django Rest Framework (DRF). It will also help you to understand the fundamentals of APIs and how to design a REST API.

Chapter 2, Exploring Django ORM, Models, and Migrations, covers how to integrate Django with a database. Django ORM and migrations are powerful features; we learn about the core concepts and how to use them efficiently in this chapter.

Chapter 3, Serializing Data with DRF, explores the concept of serialization and how developers can use DRF serializers to write better application code.

Chapter 4, Exploring Django Admin and Management Commands, covers the core concepts of Django admin. This chapter covers all the best practices on how to use Django admin and create custom Django management commands.

Chapter 5, Mastering Django Authentication and Authorization, covers the key concepts of authentication and authorization. Django provides authentication and authorization out of the box, and we will explain in detail how developers can use the built-in features of Django and DRF for authentication.

Chapter 6, Caching, Logging, and Throttling, covers all the concepts of caching and how to integrate Redis with Django for caching. Logging is a crucial component of any web application in production and, in this chapter, we will learn how to integrate logging into a Django application.

Chapter 7, Using Pagination, Django Signals, and Custom Middleware, covers all the advanced concepts of Django. Developers can use Django signals to write decoupled code. Django also gives the flexibility to create custom middleware that can help developers to improve features.

Chapter 8, Using Celery with Django, shows how to process asynchronous tasks for web applications. In this chapter, developers will get an understanding of how to integrate Celery into a Django project.

Chapter 9, Writing Tests in Django, covers the core concepts of writing test cases for Django. In this chapter, you will learn the best practices to follow while writing test cases and understand the importance of writing test cases for a project.

Chapter 10, Exploring Conventions in Django, shows all the best practices and conventions that are used while working with Django. This chapter covers a lot of concepts that are opinionated, and you are expected to read this chapter as an outline and pick/learn about concepts by using your own judgment.

Chapter 11, Dockerizing Django Applications, covers how to integrate Docker with a Django application.

Chapter 12, Working with Git and CI Pipelines Using Django, covers the concepts of version control and how to efficiently use Git in a Django project. In this chapter, you will learn how to integrate GitHub Actions to create a CI pipeline.

Chapter 13, Deploying Django in AWS, covers how to deploy Django applications in production using different AWS services. In this chapter, you will learn how to deploy and scale the Django application in production.

Chapter 14, Monitoring Django Applications, covers how to monitor Django applications in production. There are different types of monitoring needed in production, such as error monitoring, application performance monitoring, uptime monitoring, and so on. In this chapter, you will learn how to integrate different tools available on the market to monitor Django applications.

To get the most out of this book

You will need to have a basic understanding of Django and should be comfortable in writing basic Django application code. In this book, we will learn about many of the core concepts of Django and you need to be able to follow those code examples. We will introduce a lot of third-party tools/platforms that may be paid/free, and you are expected to create an account on these platforms and integrate them into the Django project.

Software/hardware covered in the book

Operating system requirements

Python 3.10 and above

Windows, macOS, or Linux

Django 4.x, Django 5.0 and above

Python packages such as celery, django-fsm, factory-boy, freezetime, django-json-widget, rest_framework

Docker

Amazon Web Services (AWS), ElephantSQL, Neon (https://neon.tech), Redis

Tools such as Rollbar, NewRelic, Better Uptime.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Django-in-Production. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Since we have specified the DemoViewVersion class, this view would only allow the v1, v2, and v3 versions in the URL path; any other version in the path would get a 404 response.”

A block of code is set as follows:

urlpatterns = [
    ...
    path('apiview-class/', views.DemoAPIView.as_view())
]

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

urlpatterns = [
    path('hello-world/', views.hello_world),
    path('demo-version/', views.demo_version),
    path('custom-version/', views.DemoView.as_view()),
    path('another-custom-version/', views.AnotherView.as_view())
]

Any command-line input or output is written as follows:

celery –-app=config beat -–loglevel=INFO

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Click on the Create New Instance button.”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Django in Production, we’d love to hear your thoughts! Please visit https://packt.link/r/1804610488 for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below

https://packt.link/free-ebook/9781804610480

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Django in Production
Published in: Apr 2024Publisher: PacktISBN-13: 9781804610480
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Arghya Saha

Arghya (argo) Saha, is a software developer with 8+ years of experience and has been working with Django since 2015. Apart from Django, he is proficient in JavaScript, ReactJS, Node.js, Postgres, AWS, and several other technologies. He has worked with multiple start-ups, such as Postman and HealthifyMe, among others, to build applications at scale. He currently works at Abnormal Security as a senior Site Reliability Engineer to explore his passion in the infrastructure domain. In his spare time, he writes tech blogs. He is also an adventurous person who has done multiple Himalayan treks and is an endurance athlete with multiple marathons and triathlons under his belt.
Read more about Arghya Saha