Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to change element in table with JavaScript
I'm using django-template and i got for loop in my template and i want to change apperance of table to look normal I guess i need to use some Javascript there but i dont know how to modify my table template.html <table id="contractTable" class="display normal table cell-border" cellsacing="0" style="width:100%"> <thead> <tr> <th class="text-center"><p class="fw-light"></p></th> <th class="text-center"><p class="fw-light">Contract</p></th> <th class="text-center" style="width: 10%"><p class="fw-light">Current</p></th> <th class="text-center"><p class="fw-light">Total</p></th> <th class="text-center"><p class="fw-light">Total_2</p></th> <th class="text-center" style="width: 10%"><p class="fw-light">% </p></th> <th class="text-center"><p class="fw-light">Type</p></th> <th class="text-center"><p class="fw-light">Files</p></th> </tr> </thead> <tbody> {% for contract in list_of_contracts %} <tr> <td class="text-center">{{ contract.CounterpartyGUID }}</td> <td>{{ contract.ContractName }}</td> <td class="text-center">{{ contract.Currency }}</td> <td class="text-center">{{ contract.SumContractWithoutVAT|floatformat:0|intcomma }}</td> <td class="text-center">{{ contract.SumContractWithVAT|floatformat:0|intcomma }}</td> <td class="text-center">{{ contract.VAT|floatformat:0 }}</td> <td class="text-center">{{ contract.ContractType }}</td> <td class="text-center"> <form action="" method="post"> {% csrf_token %} <input type="hidden" name="ref_key" value="{{ contract.ContractGUID }}"> <input type="hidden" name="contract_name" value="{{ contract.ContractName }}"> <input type="hidden" name="object_name" value="{{ object_name }}"> <input type="submit" class="btn btn-outline-primary" value="Files"> </form> </td> </tr> {% endfor %} </tbody> </table> That's how it looks I want first line to be normal and other columns be normal as well -
Full outer join in Django ORM
I have a set of models like this: class Expense(models.Model): debitors = models.ManyToManyField(Person, through='Debitor') total_amount = models.DecimalField(max_digits=5, decimal_places=2) class Debitor(models.Model): class Meta: unique_together = [['person', 'expense']] person = models.ForeignKey(Person) expense = models.ForeignKey(Expense) amount = models.IntegerField() class Person(models.Model): name = models.CharField(max_length=25) i.e. I have a many-to-many relationship between Expenses and Persons through Debitors. For a given Expense, I'd like to query all Debitors/Persons, but including Persons for which a Debitor record does not exist. In that case, I want a row with a certain person_id, but with the Debitor and Expense columns null. In other words, a FULL OUTER JOIN between Expense, Debitor, and Person. I have not found how to accomplish this with Django's ORM. I have figured out a raw query that does what I want (which is a bit more convoluted because SQLite does not natively support FULL OUTER JOINs): SELECT debitor_id as id, amount, src_person.id as person, expense_id as expense FROM src_person LEFT JOIN (SELECT src_debitor.id as debitor_id, src_debitor.amount as amount, src_expense.id as expense_id, src_debitor.person_id as person_id FROM src_debitor INNER JOIN src_expense ON src_debitor.expense_id = src_expense.id and src_expense.id = x) as sol ON src_person.id = sol.person_id; For example, for expense_id=6 this returns: id amount inhabitant expense 4 … -
I can't change the boolean value of the User model in Django
I'm trying to change a boolean field in an abstract user model in Django from False to True but I can't do it. class User(AbstractUser): boolean = models.BooleanField(default=False) image = models.ImageField(default='default.jpg', upload_to='profile-pictures', blank=True, null=True) ... def save(self, *args, **kwargs): super().save(*args, **kwargs) img = Image.open(self.image.path) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path) def View(request): user = request.user print(user.username) user.boolean is True print(user.is_vendor) user.save() return HttpResponseRedirect(reverse('profile')) -
Getting multiple checkbox value in an text area using jQuery in django
I am trying to get multiple check box values in one text area using jquerry my script <script> $(documnet).ready(function() { $('.chkcmedical').click(function() { var text = ""; $('.chkcmedical:checked').each(function() { text+=$(this).val()+"," }); text=text.substring(0,text.length-1); $('#medicalvalue').val(text); }); }); $(".demo").click(function(){ $(this).hide(200); }); </script> my checkboxes <div class="row"> <h3 class="mb-3">Have you Suffered from any of the following conditions?</h3> <div class="form-check col-3"> <input class="chkcmedical" name="medical" id="medical" type="checkbox" value="Asthma" style="margin-left: -12px; margin-right: 10px;"> <label class="form-check-label" for="medical"> Asthma </label> </div> <div class="form-check col-3"> <input class="chkcmedical" name="medical" id="medical" type="checkbox" value="Heart Disease" id="flexCheckDefault"> <label class="form-check-label" for="flexCheckChecked"> Heart Disease </label> </div> <div class="form-check col-3"> <input class="chkcmedical" type="checkbox" value="Diabetes" id="flexCheckDefault"> <label class="form-check-label" for="flexCheckChecked"> Diabetes </label> </div> my text area <div class="form-group p-5 pb-2"> <label for="exampleFormControlTextarea1">Any other conditions, operations or hospital admission details.<span class="text-danger">*</span></label> <textarea class="form-control mt-3" id="medicalvalue" rows="3"></textarea> </div> ** error when ever i click on any checkbox it doesn't their value in the text area** I tried to do this using jQuerry which i have mentioned above -
Python and Javascript interpreter behaviours [duplicate]
I am trying to solve a puzzle in python and javascript and came across a problem. Below python and javascript are giving different outputs but they are both interpreter languages. Any idea why they are working like this? Python snippet def func(a = list()): a.append(len(a)) return a print(func()) print(func()) output: [0] [0,1] Javascript snippet function func(a = []) { a.push(a.length); return a } console.log(func()) console.log(func()) output: [0] [0] -
im working on a medical expert system project, the problem is my system is failing to pass the diagnosis to the browser
below is my forms.py code class SymptomForm(forms.Form): symptoms = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['symptoms'].choices = self.get_symptoms_choices() def get_symptoms_choices(self): symptoms = Symptom.objects.order_by('name').values_list('name', flat=True) return [(symptom, symptom) for symptom in symptoms] below is my model from django.db import models class Symptom(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name below is my views code for the diagnosis function from django.shortcuts import render from .models import Symptom from .forms import SymptomForm from django.contrib.auth.decorators import login_required import pickle @login_required def diagnosis(request): with open('diagnosis/ml_model.sav', 'rb') as f: model = pickle.load(f) symptoms = Symptom.objects.order_by('name').values_list('name', flat=True) form = SymptomForm() if request.method == 'POST': form = SymptomForm(request.POST) if form.is_valid(): selected_symptoms = form.cleaned_data.get('symptoms') feature_vector = [1 if symptom in selected_symptoms else 0 for symptom in symptoms] #make prediction diagnose = model.predict([feature_vector])[0] #Display result context = {'diagnose':diagnose, 'selected_symptoms':selected_symptoms} return render(request, 'pages/diagnosis.html', context) else: form = SymptomForm() form.fields['symptoms'].choices=[(symptom,symptom) for symptom in symptoms] context = {'form':form} return render(request, 'pages/diagnosis.html', context) dignosispage thats the screenshot for my diagnosis page, i want the user to select symptoms from the symptoms list. im able to select and display the selected symptoms(i used javascript for that) under the 'Selected Symptoms' heading. When i click the diagnose page the system is returning nothing, instead it … -
How can we create a stream in graylog through Rest Api through python code
Python code with authtoken and rest api form of poat request. I want a coding solution to embed it in my project. -
django auto reloading not working when using docker
I've researched this topic for days and I could not find the right answer for me. I have my django app with postgres (postgis) and redis working just fine on the docker, but there is an issue Docker does not auto reload after change in file is made i need to rebuild whole container to get the smallest of changes. I've tried different configurations but nothing seems to work. Here is current one dockerfile FROM python:3.11.3-slim-buster WORKDIR /app ENV REDIS_HOST "redis" ENV PYTHONUNBUFFERED=1 ENV PYTHONWRITEBYTECODE 1 RUN apt-get update \ && apt-get -y install netcat gcc postgresql \ && apt-get clean RUN apt-get update \ && apt-get install -y binutils libproj-dev gdal-bin python-gdal python3-gdal RUN pip install --upgrade pip COPY ./requirements.txt ./app/requirements.txt RUN pip install -r ./app/requirements.txt COPY ./entrypoint.sh ./app ENTRYPOINT ["sh", "/app/entrypoint.sh"] COPY . ./app entrypoint python manage.py collectstatic --no-input python manage.py migrate --force daphne core.asgi:application --bind 0.0.0.0 docker compose version: "3.11.3" services: pgdb: image: kartoza/postgis container_name: postgres_gym ports: - 5432:5432 volumes: - postgres_data:/var/lib/postgresql environment: - POSTGRES_DB=${POSTGRES_DB} - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} nginx: image: nginx:latest volumes: - ./nginx:/etc/nginx/conf.d - static_files:/home/app/static ports: - "80:80" redis_app: container_name: redis image: redis:latest restart: unless-stopped ports: - 6378:6379 app_django: restart: always build: . volumes: - … -
Cache Django StreamingResponse?
I am trying to cache Django REST Framework HTTP streaming responses. My thinking is a Response sub-class can write the chunks into a temporary file as it streams, and on closing after streaming the final chunk, run a callable that copies the file into cache. from django.http import StreamingHttpResponse class CachedStreamingHttpResponse(StreamingHttpResponse): def __init__(self, streaming_content=(), *args, **kwargs): print("CachedStreamingHttpResponse init", *args) super().__init__(*args, **kwargs) def _set_streaming_content(self, value): print("CachedStreamingHttpResponse _set_streaming_content") self._buffer = TemporaryFile() self.buffered = False super()._set_streaming_content(value) def close(self): print("CachedStreamingHttpResponse close") self._buffer.seek(0) self.buffered = self._buffer return super().close() def buffer(self, b): print("CachedStreamingHttpResponse buffer") print(b) self._buffer.write(b) return b @property def streaming_content(self): print("CachedStreamingHttpResponse streaming_content") return map(self.buffer, super().streaming_content) I plan to have my cache framework pass a callable into the response close hook, something like response._resource_closers.append(set_cache). However, on making a request, I do see the CachedStreamingHttpResponse __init__ message, but none of the others (with runserver or gunicorn). I have checked, and the response is being streamed in more than one chunk (JS below). Asking early as maybe this is a fool's errand. async function readData(url) { const response = await fetch(url); const reader = response.body.getReader(); while (true) { const { done, value } = await reader.read(); if (done) { console.log("END"); return; } console.log("-> ", value); } } readData(url); -
Using the URLconf defined in e_learning.urls, Django tried these URL patterns, in this order:
this is my first time working with django and i'm getting this error. Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/student.html Using the URLconf defined in e_learning.urls, Django tried these URL patterns, in this order: admin/ [name='index'] student [name='student'] courses The current path, student.html, didn’t match any of these. i know this question was asked before but the answers didn't solve my problem. this is my views.py def student(request): if request.method == "POST": form = StudentF(request.POST) if form.is_valid(): try: form.save() return redirect('/') except: pass else: form = StudentF() return render(request, 'student.html', {'form': form}) and this is urls.py urlpatterns = [ path('student', views.StudentF, name="student"), ] forms.py class StudentF(forms.ModelForm): class Meta: model = Student fields = ['name', 'phone', 'email', 'password'] widgets = {'name': forms.TextInput(attrs={'class': 'form-control'}), 'phone': forms.TextInput(attrs={'class': 'form-control'}), 'email': forms.TextInput(attrs={'class': 'form-control'}), 'password': forms.TextInput(attrs={'class': 'form-control'}), } this is how i call my form from the navbar: <a href="student.html" class="btn btn-primary py-4 px-lg-5 d-none d-lg-block">Join Now<i class="fa fa-arrow-right ms-3"></i></a> -
Django MultipleChoiceFilter disable checks for choices
I want to add a filter for entities, which searches for list of values and return matching ones or empty list. class DistributionFilter(django_filters.FilterSet): ... survey = django_filters.AllValuesMultipleFilter("survey") ... request looks like: http://127.0.0.1:8000/api/v2/distributions/?survey=1&survey=2&isDefault=true I am getting {"survey":["Select a valid choice. 2 is not one of the available choices."]} But I just want filtered values, and don't care about input values not present in db or choices. How can I reach that? -
django sri does not recognize static files
i use django sri in my django project and im add sri to installed_app but sri not finding my static files I try this {% load sri %} {% sri "main.js" %} This working in localhost but not working on cpanel host -
how can I get GST open APIs to validate my GSTIN from that?
I am working on Register Users with GST number program. when a user enter their GST number it has to verify with the help of official GST open APIs so that we can find out that the user is actually registered with GST and company status. I need Gst apis on testing mode. I had try to get Public testing API from Master GST. I Also Found this link : https://api.mastergst.com/public/search?email=savaliya.isha160%40gmail.com&gstin=33AAECB1042N2ZW -
ImportError: cannot import name 'url' from 'django.conf.urls' cant solve this problem
I ve just cloned repository and wanted to check how it works, unfortunately my knowledge cant help here, plese can u explain what is wrong in here from django.contrib import admin from django.urls import path from django.conf.urls import url from accounts.views import home_view, signup_view, activation_sent_view, activate urlpatterns = [ path('admin/', admin.site.urls), path('', home_view, name="home"), path('signup/', signup_view, name="signup"), path('sent/', activation_sent_view, name="activation_sent"), path('activate/<slug:uidb64>/<slug:token>/', activate, name='activate'), ] I wanna тow to add sign in and sign up functions in django, for example in way where im checking other`s repositories -
Custom rendering of nested field in django-tables2
I have a table defined like this, where I want to apply custom rendering for a field: import django_tables2 as tables class SetTable(tables.Table): class Meta: model = Set fields = ( "series.title", ) def render_series_title(self, value): return 'x' For simple fields on the object itself (i.e. without a period) this works. But when there is a nested relationship (in this case, the Set model has a foreign key relationship to Series, and I want to display the Title field from the series), the custom rendering is not triggered. I have tried render_title, render_series_title, render_series__title, etc., and none of these gets called. The table is specified as the table_class in a django_filters view, and is displaying the data fine, except that it is using the default rendering and bypassing the custom rendering function. What am I missing? -
Django-admin created an empty folder
I created a virtual environment than I installed Django successfully but when i try to create a project with django-admin startproject <project_name> Django create an empty folder??[enter image description here](https://i.stack.imgur.com/zIhSf.png) I tried the C:\path\virtualenv\Scripts\django-admin startproject name_project it still doesn't work -
How Do I Allow GetObject for Public, GetObject+PutObject+DeleteObject for EC2 Instance?
I am trying to set a policy that allows GetObject for public, and GetObject, PutObject, DeleteObject for my Django application in an EC2 Instance. According to this answer, it seems that the following bucket policy should do the job: { "Version": "2012-10-17", "Id": "Policy1683280060839", "Statement": [ { "Sid": "Stmt1683280008173", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-project-bucket-2023/*" }, { "Sid": "Stmt1683280057104", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::667802944954:role/MyProject" }, "Action": [ "s3:DeleteObject", "s3:PutObject" ], "Resource": "arn:aws:s3:::my-project-bucket-2023/*" } ] } It allows GetObject for all, and in addition to that, allows DeleteObject and PutObject to IAM Role. I have assigned this role to the EC2 Instance. All public access is blocked. But I can still put objects to my bucket from localhost where I have not provided ACCESS_KEY. I have set up storage information in settings.py, but as you can see below, ACCESS_KEY is commented out. # AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID') # AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = "my-project-bucket-2023" DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" AWS_S3_CUSTOM_DOMAIN = AWS_STORAGE_BUCKET_NAME + ".s3.us-east-2.amazonaws.com" AWS_S3_FILE_OVERWRITE = False AWS_QUERYSTRING_AUTH = False I have tried a lot of other policies, and they all were not successful. How can I allow GetObject to public, deny all others, and allow GetObject, PutObject, … -
Woocommerce and Stripe - Get default payment method
Im doing a proyect in Django that is connected to woocommerce and stripe, the point is that im doing a subscription manually and I face the following problem. If in the wordpress web the user want to change his default payment method, as the subscription is just a normal product there, I find no way to get that. I know that in the database its stored the default payment method, and that the payment method is created in stripe. I need to be able to check from django how to know if default payment method has changed and how to get the stripe id of the new payment method. Thank you very much! Im searching for information but i see no way to handle it. -
Time zone problem with Django's BaseDatabase cache expiry
I'm using Django's cache framework with the Database backend. I'm using USE_TZ=True, and the TIME_ZONE of my databases are set to: America/New_York. I'm using sqlite for testing and Oracle in production both of which doesn't support time zones, which should mean that Django will read/write datetimes as America/New York time. The problem I see is that the cache backend always determines the expiry to be in UTC - which is great - but then before the insert it simply converts this to a string without localizing and that's what gets set in the database. This means if I set expiry as 120 seconds at 5:00 AM in America/New_York time: Django will look at the UTC time, adds the 120 seconds (so expiry will 9:02 AM in UTC) and it will simply insert 9:02 into the database. However when Django reads this value back, it will be read as 9:02 in America/New_York TZ, hence there's additional 4 hours to the intended 2 mins of expiry. Stepping through the source code I think the issue is that the logic for determining "exp" (for the insert) is different than for "current_expires" (read operation for expiry of existing record). For "exp" the value will … -
Problems with DjOngo
I am doing some small exercises using mongodb and when I do 'from djongo.models.fields import ObjectIdField, Field' and start the server I get this: Import "djongo.models.fields" could not be resolved - Pylance(reportMissingImports) I think I have run the 'pip' correctly and these are the versions of the installed packages: asgiref==3.6.0 certifi==2022.12.7 charset-normalizer==3.0.1 crispy-tailwind==0.5.0 Django===4.0.1 django-crispy-forms===2.0 djongo===1.3.6 dnspython==2.3.0 idna==3.4 pymongo==3.12.1 python-dotenv==0.21.1 pytz===2022.7.1 requests===2.28.2 sqlparse===0.2.4 tzdata===2023.3 urllib3==1.26.14 whitenoise===6.3.0 -
About dashboard manipulation
enter image description here I am not able to insert any thing in my dashboard section. Please see this image. In the dashboard section I want to insert Images like Barcharts, Piecharts and other things. But i am able to see only the 'Authentication and Authorization', my django app name and Model and Recent actions. I want to overwrite them. I just wanna customize the dashboard section. The url is localhost/admin/. in the same url i want the things. In in the right of side bar i want the images in dashboard section for fetching the real datas. enter image description here I have tried to customize the JAZZMIN dashboard section whose url is localhost/8000/ -
Periodic tasks not running with Celery, Django and Redis
I am developing an application under Django which aims to allow users to create scheduled tasks. These tasks are in fact a script which returns its results in a log file. The problem is that the tasks are not executed, yet they are added in the beat scheduler and Redis receives the tasks to put in its queue. Here is to start the content of my settings.py (a part): # [...] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp.apps.MyappappConfig', 'bootstrap5', 'django_celery_beat', 'django_celery_results' ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'database_myapp', 'USER': 'toto', 'PASSWORD': 'toto', 'HOST': 'localhost', 'PORT': '3306', } } # [...] ### CONFIG FOR CELERY # save Celery task results in Django's database CELERY_RESULT_BACKEND = "django-db" # This configures Redis as the datastore between Django + Celery CELERY_BROKER_URL = "redis://localhost:6379/0" # this allows to schedule items in the Django admin. CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers.DatabaseScheduler' CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_TIMEZONE = 'Europe/Paris' Here my celery.py : from __future__ import absolute_import import os from celery import Celery from django.conf import settings # set the default Django settings module for the 'celery' program. # this is also used in manage.py os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") app = Celery("myapp") # Using … -
Django: Sum by date and then create extra field showing rolling average
I would like to create a Sum in a Model by date and then add a rolling average ... in one query. Is this possible? Let's say I have a table like this, called "Sales": |---------------------|------------------|--------------| | Date | Category | Value | |---------------------|------------------|--------------| | 2020-04-01 | 1 | 55.0 | |---------------------|------------------|--------------| | 2020-04-01 | 2 | 30.0 | |---------------------|------------------|--------------| | 2020-04-02 | 1 | 25.0 | |---------------------|------------------|--------------| | 2020-04-02 | 2 | 85.0 | |---------------------|------------------|--------------| | 2020-04-03 | 1 | 60.0 | |---------------------|------------------|--------------| | 2020-04-03 | 2 | 30.0 | |---------------------|------------------|--------------| I would like to group it by Date (column "Category" is unimportant) and add the Sum of the values for the date. Then I would like to add a rolling Average for the last 7 days. I tried this: days = ( Sales.objects.values('date').annotate(sum_for_date=Sum('value')) ).annotate( rolling_avg=Window( expression=Avg('sum_for_date'), frame=RowRange(start=-7,end=0), order_by=F('date').asc(), ) ) .order_by('date') This throws this error: django.core.exceptions.FieldError: Cannot compute Avg('sum_for_date'): 'sum_for_date' is an aggregate Any ideas? -
When I run my Docker :pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")
I am on windows11 and I have created an API with django and venv. My API deploys a time series model. For the database, I don't have a script to initialize the database, my database comes from an external DB with Microsoft SQL Manager, I am connected to this database using pyodbc! Here is the file with which I connect to the database: import pyodbc import os from dotenv import load_dotenv load_dotenv() def connect_to_database(): db_server = os.environ.get('DB_SERVER') db_name = os.environ.get('DB_NAME') db_user = os.environ.get('DB_USER') db_password = os.environ.get('DB_PASSWORD') db_encrypt = os.environ.get('DB_ENCRYPT') db_trusted_connection = os.environ.get('DB_TRUSTED_CONNECTION') db_driver = 'SQL Server' conn = pyodbc.connect( DRIVER=db_driver, SERVER = db_server, DATABASE = db_name, ENCRYPT = db_encrypt, UID = db_user, PWD = db_password, Trusted_Connection = db_trusted_connection) return conn Then I tried to create my docker image and here is my Dockerfile : # Use an official Python runtime as a parent image FROM python:3.9-slim-buster # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app COPY . /app # Set environment variables ENV SECRET_KEY=$SECRET_KEY \ DEBUG=$DEBUG \ ALLOWED_HOSTS_1=$ALLOWED_HOSTS_1 \ ALLOWED_HOSTS_2=$ALLOWED_HOSTS_2 \ AGENCY_1=$AGENCY_1\ DB_SERVER=$DB_SERVER \ DB_NAME=$DB_NAME \ DB_USER=$DB_USER \ DB_PASSWORD=$DB_PASSWORD \ DB_ENCRYPT=$DB_ENCRYPT \ DB_TRUSTED_CONNECTION=$DB_TRUSTED_CONNECTION # Install any needed packages specified … -
Why does psycopg2 raise a postgreSQL error when deploying Django site to Heroku?
I am trying to deploy my Django site to heroku and get the following error snippet: 2023-05-05T08:42:38.330672+00:00 app[web.1]: from psycopg2._psycopg import ( # noqa 2023-05-05T08:42:38.330672+00:00 app[web.1]: SystemError: initialization of _psycopg raised unreported exception 2023-05-05T08:42:38.330718+00:00 app[web.1]: [2023-05-05 08:42:38 +0000] [8] [INFO] Worker exiting (pid: 8) 2023-05-05T08:42:38.367087+00:00 app[web.1]: [2023-05-05 08:42:38 +0000] [2] [WARNING] Worker with pid 8 was terminated due to signal 15 2023-05-05T08:42:38.465035+00:00 app[web.1]: [2023-05-05 08:42:38 +0000] [2] [INFO] Shutting down: Master 2023-05-05T08:42:38.465071+00:00 app[web.1]: [2023-05-05 08:42:38 +0000] [2] [INFO] Reason: Worker failed to boot. 2023-05-05T08:42:38.616316+00:00 heroku[web.1]: Process exited with status 3 2023-05-05T08:42:38.666808+00:00 heroku[web.1]: State changed from starting to crashed 2023-05-05T08:42:39.000000+00:00 app[api]: Build succeeded 2023-05-05T08:42:44.863150+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=a-coders-journey.herokuapp.com request_id=d8e2f6b2-c4f5-461f-8914-a8e84dc13551 fwd="93.204.33.78" dyno= connect= service= status=503 bytes= protocol=https I have ensured the version of my requirements.txt file has the binary version (psycopg2-binary), and all applicable requirements: # # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # # pip-compile --output-file=requirements.txt requirements.in # asgiref==3.3.4 # via # -r requirements.in # django certifi==2022.12.7 # via # cloudinary # requests cffi==1.15.1 # via cryptography charset-normalizer==3.1.0 # via requests cloudinary==1.25.0 # via # -r requirements.in # dj3-cloudinary-storage cryptography==3.4.8 # via # -r requirements.in # pyjwt defusedxml==0.7.1 # …