What is WSGI and Why Do You Need Gunicorn and Nginx in Django

In this article, we’re going to talk about WSGI, Gunicorn, and Nginx. We will discuss why you need these things, and how they work together with Django. Here’s the video if you prefer watching over reading: The article will help you understand the process of deploying Django application better and I hope that at the end of it, you will understand what the heck is…

Read More

Introduction to SQLAlchemy ORM for Django Developers

I always used Django at work and for my personal projects. But on the recent project at work I had an opportunity to use Flask with SQLAlchemy. So I had to learn something new. Flask is easy peasy because it’s a microframework and it doesn’t have a lot inside. However, understanding SQLAlchemy and how to work with it was more difficult than I expected. In…

Read More

Django + Elasticsearch. Searching for awesome TED Talks

In the article we’re going to cover the basics of Elasticsearch: what it is, how to run it, how to communicate with it. Then, after we feel comfortable with Elasticsearch, we will start developing a simple web application with Django that will use the power of Elasticsearch. Running Elasticsearch Before diving into the concepts of Elasticsearch we should run it first. When you start reading…

Read More

Distributed systems with RabbitMQ

In this article, we’re going to talk about the benefits of distributed systems and how to move to distributed systems using RabbitMQ. Then we will learn the fundamentals of RabbitMQ and how to interact with it using Python. Distributed systems In this section, we’re going to learn the importance of distributed systems. If you’re interested in learning this by watching a video, then here it…

Read More

Django + GraphQL. Solving N+1 Problem using DataLoaders

In this article we’re going to focus on specific problem which you will probably face if you start developing GraphQL APIs. I will try to explain the problem first and then show you how it can be solved using DataLoaders. N+1 Problem Imagine that you’re developing a blog. Your server should provide GraphQL API so that your client app written in React, Vue or Angular…

Read More

Let’s talk about data structures in Python

Data structures is a way to store and organize data. Obviously, some data structures are good in one set of problems, but terrible in other ones. The right choice of data structure can make your code faster, more efficient with memory and even more readable for other human beings. In this article we are going to discuss the most important data structures in python. How…

Read More

Django + React + TS. How to create and consume GraphQL API

This article is dedicated to GraphQL. I will explain what GraphQL is and what advantages it has over REST. Then we will create a simple web application that exposes GraphQL API on server-side and consumes it on client-side. Stack on server-side: Python; Django; Graphene Django for creating GraphQL API. Stack on client-side: TypeScript; React; React Apollo for interacting with GraphQL API. Also I will show…

Read More

Как начать Django проект, который можно масштабировать

В статье создадим проект используя шаблонизатор cookiecutter-django, настроим статическую типизацию, добавим автоматическое форматирование кода с помощью black, создадим скрипт, который запускает тесты, проверяет правильность типов через линтер mypy и стиль кода через black. Напоследок добавим пре-коммит хук, который автоматически запускает скрипт с проверками перед каждым коммитом. Содержание Создаем проект с помощью cookiecutter-django Библиотеки Настройки Веб-сервер и Gunicorn Запускаем проект Настраиваем статическую типизацию Форматируем код с…

Read More

Celery + Channels = <3. Создаем реал-тайм приложение с бэкграунд тасками

В статье создадим веб-приложение, которое в бэкграунде делает запросы к API со случайными шутками каждые 15 секунд, затем отправляет шутку пользователю через WebSocket. Для реализации приложения будем использовать: django, celery и channels. Celery для бэкграунд задач. Channels для передачи сообщений через WebSocket. Конечный результат на картинке: Исходный код проекта: https://github.com/apirobot/django-channels-celery-jokes Содержание Что такое celery Что такое channels Создаем проект Создаем приложение Создаем бэкграунд задачу Подключаем библиотеку…

Read More