8 Django Tips and Tricks Learned Over the Years

After working with Django for more than 4 years both professionally and personally, I have learned a lot of tips and tricks that I wish I knew when I started. In this article I will share some of the most important ones that I have learned over the years. Since Django documentation is very good, I will not share many code snippets, but rather explain the concepts and provide links to the official documentation. All of these tips and tricks came from my own experience, the Django documentation, and Two Scoops of Django book. ...

November 12, 2024 · 7 min · Gaëtan Grond

Protecting Data in Django Admin: Preventing Accidental Deletions

The Django admin interface is one of the standout features that make Django such a powerful framework. It allows you to manage your data, customers, and models with ease. However, as with any tool that provides significant control over your application’s data, there’s a need to ensure that sensitive actions like deletions are handled carefully. ...

September 23, 2024 · 3 min · Gaëtan Grond

Storing List in Models with Django

Lists or arrays are commonly used data types in programming. However, Django does not have a built-in field for storing lists in models. In a recent project, I needed to store a list of strings in a model, and I had to find an elegant and efficient way to store the list in the database. ...

September 4, 2024 · 5 min · Gaëtan Grond

Fluent Python - My Private Notes

These are my personal notes from reading Fluent Python. They’re a bit scattered, but I’ve found them useful for understanding some of Python’s more advanced features, like decorators, generators, and defensive programming. I’m sharing them here in case they’re helpful to others working through similar topics or if you’re considering reading the book. ...

August 25, 2024 · 13 min · Gaëtan Grond

Create a Simple Maintenance Feature in Django

When working with Django for my startup I performed in several occasions very complex migrations and maintenance tasks that required the site not to be accessible for a few minutes and sometimes even hours. Even if the end user is not able to access the site, our team of superusers and admins should be able to access the site and perform the maintenance tasks. ...

August 5, 2023 · 5 min · Gaëtan Grond

Secure Your Django Administration with 6 simple steps

One of the most loved features of Django is the built-in administration interface. It allows for an easy way to manage your data and is highly customizable. However, it is also a very common target for attackers. In this article, we will look at some of the most common attacks against the Django administration interface and how to protect against them. ...

August 3, 2023 · 8 min · Gaëtan Grond

How to Customize The CSRF Failure View in Django

When working with Django and third party libraries, you may encounter a CSRF error on login or any other form submission. This is because Django requires a CSRF token to be sent with every form submission except GET requests or if the form has the csrf_exempt decorator. During my work with Django, I have encountered this error many times, sometimes due to my own mistakes and sometimes due to third party libraries or user behavior. ...

August 1, 2023 · 3 min · Gaëtan Grond

Django 4.2.0 - What's New?

Django 4.2 has been released with a host of new features and fixes, including support for Psycopg3, a new way to create users with a ModelForm of the User model, and a new option to merge model changes into the latest migration. Here’s an overview of the most notable changes in Django 4.2: ...

April 3, 2023 · 2 min · Gaëtan Grond