Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Django in Production

You're reading from  Django in Production

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781804610480
Pages 348 pages
Edition 1st Edition
Languages
Author (1):
Arghya Saha Arghya Saha
Profile icon Arghya Saha

Table of Contents (21) Chapters

Preface 1. Part 1 – Using Django and DRF to Build Modern Web Application
2. Chapter 1: Setting Up Django with DRF 3. Chapter 2: Exploring Django ORM, Models, and Migrations 4. Chapter 3: Serializing Data with DRF 5. Chapter 4: Exploring Django Admin and Management Commands 6. Chapter 5: Mastering Django Authentication and Authorization 7. Part 2 – Using the Advanced Concepts of Django
8. Chapter 6: Caching, Logging, and Throttling 9. Chapter 7: Using Pagination, Django Signals, and Custom Middleware 10. Chapter 8: Using Celery with Django 11. Chapter 9: Writing Tests in Django 12. Chapter 10: Exploring Conventions in Django 13. Part 3 – Dockerizing and Setting Up a CI Pipeline for Django Application
14. Chapter 11: Dockerizing Django Applications 15. Chapter 12: Working with Git and CI Pipelines Using Django 16. Part 4 – Deploying and Monitoring Django Applications in Production
17. Chapter 13: Deploying Django in AWS 18. Chapter 14: Monitoring Django Application 19. Index 20. Other Books You May Enjoy

Working with Git and CI Pipelines Using Django

In Chapter 11, we learned how to integrate Docker into a Django project. Docker helps us to run our Django project on any platform seamlessly. In this chapter, we shall explore how to use Git efficiently while working with a Django project. We shall learn about the best practices for using Git and how to integrate Git hooks into the development cycle to increase the productivity of developers.

We will be learning about the following topics in this chapter:

  • Using Git efficiently
  • Working with GitHub and setting up GitHub Actions
  • Setting up PR review and code guidelines

Technical requirements

In this chapter, we shall work with advanced Git features and integrate GitHub Actions into our project. We are expecting our readers to have a good understanding of Git and some knowledge about continuous integration (CI) pipelines using GitHub Actions.

If you are not familiar with Git, we highly recommend you learn the basics of Git and come back to this chapter. Here are a few resources, including books and free courses, that you can follow:

Here is the GitHub repository that has all the code and instructions for this chapter: https://github.com/PacktPublishing...

Using Git efficiently

Version control is one of the most important tools in the software development lifecycle (SDLC). We will not go into the basics of Git in this chapter, but rather we will discuss the good practices one should follow while using Git. Let us look into a few good practices that are recommended while using Git:

  • Always create a new branch event for small changes. A lot of times, developers get tempted to directly commit their changes to main, master, develop, or any other name used for the default branch, depending upon what they are using.
  • Add a .gitignore file as soon as you create a project.
  • Never allow anyone to have access to push code to the default branch. Every piece of code should be merged to the default branch using a pull request (PR).
  • Always make sure Git is configured locally and has the developer’s name, email, and other relevant details.
  • Use the git merge command strategy while merging two branches and avoid using rebase...

Working with GitHub and GitHub Actions

Multiple platforms such as GitHub, GitLab, and Bitbucket can provide code repository hosting solutions. GitLab is an open source project that can be also used to host our own GitLab server. Currently, GitHub and GitLab are the main market leaders. We shall be discussing GitHub in this book and will not be looking into GitLab; if you are using GitLab or any other platform, you can skip this section and move to the next section of the chapter.

Here are a few important features/settings/configurations we would like our readers to be aware of while working with GitHub:

  • Always use Organization for projects that are not personal: GitHub provides an interface to create an organization, which will help in organizing all the repositories better.
  • Enable 2FA for all users: A code base is one of the most sensitive components of an organization hence security measures should be the priority.
  • Configure rulesets: Branch rulesets help to enforce...

Setting up code review guidelines

Code review is the quality assurance process of any code change made to the code base. It is one of the loved and equally hated processes in the development cycle. The code review process, if implemented properly, can help create a great experience for the developers and fast track the product development cycle. But if the code review process is implemented appropriately, then it can become a bottleneck for the velocity of the company, and developers might become hostile toward doing code review, and a lot of times they may cause more issues. The code review process should be implemented by the early members of the team and should be continuously improved and adapted as the company/product/team grows. There are no definitive guidelines and it falls to team members to set up the guidelines that suit their situation. However, let us look into a few code review guidelines that are followed across the industry.

Context and description

Whenever a...

Summary

In this chapter, we have learned how to use Git efficiently. We have explored different recommended good practices that can ease the SDLC and also help in writing better maintainable code. Git hooks can help us automate a lot of linting and we have learned how we can use Git hooks in our project. We also saw how we can use GitHub and GitHub Actions in the Django project, which can help us automate multiple workflows. Code review is a process that needs guidelines, and we have learned how to create different guidelines for code review. We have also seen different aspects of PR review and how to implement guidelines for PR review in the team to improve a good coding culture.

In the next chapter, we will explore how to deploy our Django code to the cloud using Amazon Web Services (AWS). AWS is the leading cloud service provider currently available in the market. We shall discuss more about AWS in our next chapter and learn how to deploy our Django application using AWS.

...
lock icon The rest of the chapter is locked
You have been reading a chapter from
Django in Production
Published in: Apr 2024 Publisher: Packt ISBN-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.
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}