Django Performance Improvements. Part 1: Database Optimizations | by Esther Vaati | Jun, 2022

Part 1: Database Optimizations Photo by Ivan Diaz on Unsplash The main goal of optimization in Django projects is to make it fast to perform database queries by ensuring that your projects run by making the best use of system resources. A properly optimized database will reduce the response time hence a better user experience. … Read more

amazon web services – 502 Bad Gateway nginx/1.20.0 Error when Deploying Django app using AWS Elastic Beanstalk

I was following closely following AWS’s documentation on how to deploy Django apps using Elastic Beanstalk until I received a 502 Bad Gateway nginx/1.20.0 Error when opening my app. From there, I followed a couple of solutions offered by users that suffered similar problems. Specifically, I added a Procfile and went about editing how my … Read more

python – Django does not display errors from the custom validator, and instead resets the form

I recently started learning Django and can’t solve one problem. I created my validator for the form, but instead of showing an error window, it just resets the form. Here is the code from django.db import models from django.urls import reverse_lazy from django.core.exceptions import ValidationError class News(models.Model): title = models.CharField(max_length=150, verbose_name=”Title”) content = models.TextField(blank=True, … Read more

python – Django serializer requiring a dict instead of a model instance

I’m trying to make a really simple serialization in a viewset in django, but my serializer, which should require the instance to be serialized, is requiring a dict. This is my custom serializer: class JSONAPIModelSerializer(serializers.ModelSerializer): def __init__(cls, *args, **kwargs): if kwargs.get(‘many’, False) is True: context = kwargs.get(‘context’, {}) context.update({‘is_many’: True}) kwargs.update({‘context’: context}) return super().__init__(cls, *args, … Read more

javascript – JS script runs partially on heroku but fully locally (Django)

document.addEventListener(‘DOMContentLoaded’, function () { // get button by id // document.getElementById(‘closedjs_$’).style.display=’none’; var trips = document.querySelectorAll(‘*[id^=”closedjs”]’); // trips = document.querySelectorAll(‘.closedjs’) trips.forEach((element) => { = ‘none’; }); // checking if current passengers >= max passengers so changing Join btn to Closed /*document.querySelectorAll(‘.joinleave’).forEach((element) => { var route_id =; var no_pass = parseFloat(document.querySelector(`#thepassengercounter_${route_id}`).innerHTML); var max_pass = parseFloat(document.querySelector(`#max_pass_${route_id}`).innerHTML); … Read more

python – Getting Errors while starting mod wsgi (Django app) via apache

Starting up a dockerised django application as a mod wsgi app via apache. Getting an endless stream of below errors. Errors: 2022-06-02 16:05:12.225137 [notice] [pid 10002] mpm_unix.c(436): [client AH00052: child pid 10992 exit signal Aborted (6) 2022-06-02 16:05:12.225382 [info] [pid 10002] src/server/mod_wsgi.c(7761): [client mod_wsgi (pid=10992): Process ‘’ has died, deregister and restart it. 2022-06-02 16:05:12.225411 … Read more

Django POST requests from Postman forbidden after HEROKU DEPLOYMENT

I uploaded my Django REST Framework project to Heroku after following the steps carefully. In my project, I used BEARER tokens with jwt. My database is PostgreSQL which is provided by Heroku. It worked perfect while working locally but after deployment, I couldn’t send requests through Postman. Any ideas? 2022-06-04T16:36:50.456061+00:00 heroku[router]: at=info method=POST path=”/api/login” … Read more

python – How to get rid of pytz UnknownTimeZoneError in my Django logs?

The bounty expires in 4 days. Answers to this question are eligible for a +50 reputation bounty. May.D wants to draw more attention to this question. I’ve a Django Application on Windows Server 2022 and error logs are flooded with the following message: pytz.exceptions.UnknownTimeZoneError: ‘Europe/Paris’r, referer: https://my_server_url During handling of the above exception, … Read more