Articles about Django

Class-based vs Function-based Views in Django

In this article, we'll look at the differences between Django's class-based views (CBV) and function-based views (FBV). We'll compare and contrast and dive into the pros and cons of each approach (along with Django's built-in generic class-based views). By the end, you should have a good understanding of when to use one over the other.

Securely Deploy a Django App With Gunicorn, Nginx, & HTTPS

Taking a Django app from development to production is a demanding but rewarding process. This tutorial will take you through that process step by step, providing an in-depth guide that starts at square one with a no-frills Django application and adds in Gunicorn, Nginx, domain registration, and security-focused HTTP headers. After going over this tutorial, you’ll be better equipped to take your Django app into production and serve it to the world.

Automatically Retrying Failed Celery Tasks

In this article, we'll look at how to automatically retry failed Celery tasks.

Django REST Framework and Elasticsearch

In this tutorial, we'll look at how to integrate Django REST Framework (DRF) with Elasticsearch. We'll use Django to model our data and DRF to serialize and serve it. Finally, we'll index the data with Elasticsearch and make it searchable.

Dockerizing Django with Postgres, Gunicorn, and Nginx

This is a step-by-step tutorial that details how to configure Django to run on Docker with Postgres. For production environments, we'll add on Nginx and Gunicorn. We'll also take a look at how to serve Django static and media files via Nginx.

Asynchronous Tasks with Django and Celery

If a long-running process is part of your application's workflow, rather than blocking the response, you should handle it in the background, outside the normal request/response flow.

Effectively Using Django REST Framework Serializers

In this article, we'll look at how to use Django REST Framework (DRF) serializers more efficiently and effectively by example. Along the way, we'll dive into some advanced concepts like using the source keyword, passing context, validating data, and much more.

Handling Periodic Tasks in Django with Celery and Docker

As you build and scale a Django app you'll inevitably need to run certain tasks periodically and automatically in the background.

Working with Celery and Django Database Transactions

In this article, we'll look at how to prevent a Celery task dependent on a Django database transaction from executing before the database commits the transaction. This is a fairly common issue.

Django Channels and WebSockets

For more than a decade after Django was first released in 2005, pages were mostly static, AJAX was used only in limited use cases, and things were relatively uncomplicated. Over the past five years, real-time web applications have evolved, trending toward more client-server and peer-to-peer interaction. This type of communication is achievable with WebSockets, a new protocol that provides full-duplex communication and maintains a persistent, open connection between client and server.

Building a REST API in Django is so super easy. In this tutorial, we’ll walk through the steps to get your first API up and running.

What is Django Channels?

If, like me, you've done any research to answer this question, you've found that you can build a chat app. There are 100 if not more guides out there to help you build your next Slack. There aren't many tutorials, blogs, documentation, or other resources to help you do much more with Django Channels.

Modern Python Environments - dependency and workspace management

Once you get through the pain of setting up a Python environment for a single "hello world"-esque application, you'll need to go through an even more difficult process of figuring out how to manage multiple environments for multiple Python projects. Some of the projects could be new while others are stale piles of code from ten years ago. Fortunately, there a number of tools available to help make dependency and workspace management easier.