Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
continues error on "Could not find 'Price' Did not find price on detail page" in django
im begginer in django , leanring through coursera , django for everyone course , while doing my assignment repeated error throwing contiusely while submitting this is error,and i checked everthing but its still throwing error but "price" is there in web here my view.py in django- from ads.models import Ad from ads.owner import OwnerListView, OwnerDetailView, OwnerCreateView, OwnerUpdateView, OwnerDeleteView class AdListView(OwnerListView): model = Ad class AdDetailView(OwnerDetailView): model = Ad class AdCreateView(OwnerCreateView): model = Ad fields = ['title', 'text', 'price'] class AdUpdateView(OwnerUpdateView): model = Ad fields = ['title', 'text', 'price'] class AdDeleteView(OwnerDeleteView): model = Ad and here is my ad_detail.html --- {% extends "base_menu.html" %} {% block title %}{{ settings.APP_NAME }}{% endblock %} {% load humanize %} <!-- https://docs.djangoproject.com/en/3.0/ref/contrib/humanize --> {% block content %} <span style="float: right;"> ({{ ad.updated_at|naturaltime }}) {% if ad.owner == user %} <a href="{% url 'ads:ad_update' ad.id %}"><i class="fa fa-pencil"></i></a> <a href="{% url 'ads:ad_delete' ad.id %}"><i class="fa fa-trash"></i></a> {% endif %} </span> <h1>{{ ad.title }}</h1> <p> {{ ad.text }} </p> <p> {{ ad.price }} </p> <p> <input type="submit" value="All Ads" class="btn btn-primary " onclick="window.location.href='{% url 'ads:all' %}';return false;"> </p> {% endblock %} im using pythonanywhere for django and assignment python manage.py check --ok python manage.py makemigrations --ok python … -
Django Rest filter and filerset_class not working in custom action method
I'm having issues getting the filterset_class work in my view's action method. When I filter the data in /api/measurement/aggregated_data everything works fine, but I need to use these filters in my action method as well, so I can download the results. Here's my views.py: class AggregatedDataViewSet(ReadOnlyModelViewSet): serializer_class = AggregatedDataSerializer queryset = AggregatedData.objects.all() filter_backends = [DjangoFilterBackend, OrderingFilter, SearchFilter] filterset_class = AggregatedDataFilter search_fields = ['parameter__measurand__name', 'river_site__lawa_code'] @action(detail=False, methods=['get'], url_path='download') def download(self, request, *args, **kwargs): qs = self.filterset_class(self.get_queryset()) # rest of the code... I apply filters in filterset_class in /api/measurement/aggregated_data and the url changes as well and will look something like this: http://127.0.0.1:8003/api/measurement/aggregated_data/?parameter__lawa_code=1234&sample_medium=&sampling_type=&year_from=2015&year_to=2015&river_site=BVNM When I click the download action, qs returns all data, so the filters are not applied. I want these filters in the url to be applied to the download method as well, but somehow they are not recognized by it. What is going wrong here and what is the best way to do what I am expecting? -
ModuleNotFoundError: No module named 'django.utils.six.moves'
While deploying my Django code on AWS EC2 server I'm getting the error below. I uninstalled six many times and deleted the cache folder and installed different versions of six but none of working. I have been facing this issue for the last 2 days but still haven't gotten a solution, please help me to get rid from this. May 22 17:06:33 ip-172-31-7-56 gunicorn[73506]: from storages.backends.s3boto3 import S3Boto3Storage May 22 17:06:33 ip-172-31-7-56 gunicorn[73506]: File "/home/ubuntu/lighthousemedia/.venv/lib/python3.12/site-packages/storages/backends/s3boto3.py", line 12> May 22 17:06:33 ip-172-31-7-56 gunicorn[73506]: from django.utils.six.moves.urllib import parse as urlparse May 22 17:06:33 ip-172-31-7-56 gunicorn[73506]: ModuleNotFoundError: No module named 'django.utils.six.moves' -
TypeError at /post/guest/2 __init__() takes 1 positional argument but 2 were given
urls.py path('post/guest/<int:pk>', PostDetailViewGuests, name='post-detail-guests'), class PostDetailViewGuests(HitCountDetailView): model = PostForGuestsFeed template_name = 'feed/post_detail.html' context_object_name = 'post' slug_field = 'slug' # set to True to count the hit count_hit = True def get_context_data(self, **kwargs): context = super(PostDetailViewGuests, self).get_context_data(**kwargs) context.update({ 'popular_posts': PostForGuestsFeed.objects.order_by('-hit_count_generic__hits')[:3],'page_title': 'Shared Post' }) return context template file: <a class="btn btn-info btn-sm" href="{% url 'post-detail-guests' post.id %}" >Read More &rarr;</a > -
How to retrieve Django Post parameters
I'm sending data from Javascript like this: let payload = { cmd: document.getElementById('cmdInput').value } console.log('Sending payload', payload) fetch('/runNgen/', { method: "POST", body: JSON.stringify(payload), headers: { "Content-Type": "application/json" } }) The Post operation seems to work. But on the Django side, I have @api_view(['POST']) def run_ngen(request): print("params", request.POST.keys()) and the parameters are empty. What am I doing wrong? -
Saving a fabri.js canvas to postgres database
I'm trying to save my canvas and few other data to my postgres database. In the React frontend i created an interface and a method to send my data to the Django backend. The problem I got, is that I always get the following message from the server: {sucess: false, error: "Canvas() got unexpected keyword arguments: 'data'"} error: "Canvas() got unexpected keyword arguments: 'data'" sucess: false Here is my frontedn code: import { Button } from "@mui/material"; import fabric from "fabric/fabric-impl"; import { saveCanvasData } from "../api/CanvasApi"; import { Canvas } from "../model/Canvas"; export const SaveCanvasButton = ({ fabricRef, }: { fabricRef: React.MutableRefObject<fabric.Canvas | null>; }) => { const handleClick = () => { const jsonCanvas = JSON.stringify(fabricRef.current?.toJSON()); const canvasData: Canvas = { aedate: new Date(), aeuser: "test", data: jsonCanvas, edate: new Date(), euser: "test", pid: "test", }; console.log(canvasData); if (canvasData) { saveCanvasData(canvasData); } }; return ( <Button onClick={handleClick} color="inherit"> Canvas Speichern </Button> ); }; Backend Code: from django.db import models from django.core.validators import RegexValidator # Validierung des Inputs gem. Datenmodell mit regulären Ausdrücken ID_validator = RegexValidator( regex=r"^\d{0,7}[1-9]$", message="Die ID muss eine Länge von 8 haben und darf nicht mit Null beginnen.", code="invalid_id", ) class Canvas(models.Model): # CID = models.CharField(max_length=8, … -
Pre-populate edit form with existing product description in Django
I'm building a Django inventory app and have a Product model with various fields. I've implemented an edit button for each product row that allows users to update information. However, when clicking the edit button, the form appears empty for all fields. I want the edit form to automatically display the existing product information for each field, so users only need to modify specific details. This eliminates the need to retype everything. I've searched the Django documentation on forms, but I'm unsure how to achieve this pre-population for the edit functionality. How can I pre-populate the edit form with the existing product information in my Django inventory app? def edit_product(request, pk): product = get_object_or_404(Product, pk=pk) if request.method == 'POST': form = ProductForm(request.POST, instance=product) if form.is_valid(): form.save() return redirect('product_list') else: form = ProductForm(instance=product) return render(request, 'inventory/edit_product.html', {'form': form}) -
How to authenticate users in Django and store data in Supabase in real-time?
I have a Django server with a user database stored in MySQL. I'm using Django Rest Framework and Django Allauth for user authentication. I want to build another application for storing user questions. The data for these questions should be stored in Supabase. I want to authenticate users with the Django server, and only authenticated users with the required authorization should be able to ask questions in the other application. Here's what I want to achieve: User logs in through the Django server (using Django Allauth). Once authenticated, the user can ask questions in the other application. The questions are stored in Supabase in real-time. Only authenticated users with the required authorization can ask questions. I'm not sure how to integrate Django with Supabase and handle real-time data updates. I also want to ensure that the authentication and authorization processes are secure and efficient. I have checked the documentation of supabase but I haven't found any information about third party authentication except the social the authentication that's what I noticed, maybe I missed someting. Any guidance or resources on how to achieve this would be greatly appreciated. Thanks in advance! P.S: I want to take advantage of the real time … -
Why is my Django mode object not appending my random ID generated tag to my URL?
Right, I am literally about to loose my temper. I have a Django model, with an object. I have a fucntion which generated a random ID, appends it to the model object and places it on the end of the URL. Thats the theory anyway, but just like everything else in my life, nothing works. I have a great big neon sign that is only invisible to me which stated "Please piss this guy off as much as you possibly can!" You have no idea how sick to death I am of this. It's so silly! It's so unfair and I am going to fume. In my urls.py I have: ``from django.urls import path, include from . import views urlpatterns =[ path('',views.careers, name="careers"), path('apply/<str:careers_reference>',views.apply), ]`` In my views.py I have: `from django.shortcuts import render, redirect, get_object_or_404 from django.core.mail import send_mail, BadHeaderError from django.http import HttpResponse, HttpResponseRedirect from django.template import loader from . models import Careers import logging from xxxx import utils def apply(request, careers_reference): career_detail = get_object_or_404(Careers,careers_reference = careers_reference) template = loader.get_template('careers-details.html') context = { 'career_detail' : career_detail, } return HttpResponse(template.render(context, request))` In my models.py, I have `from django.db import models from . import utils # Create your models here. … -
Adding extra layer of security(OTP) to a website
I’m unable to use Django admin to add device. I have a feeling the problem is in the urls.py file. This is the content From django.contrib import admin from django.urls import path from django_otp.admin import OTPAdminSite admin.site__class__=OTPAdminSite urlpatterns = [ path(‘admin/‘, admin.site.urls), ] I tried logging in to the localhost:8000/admin/. Although it was successful, it prompted ‘choose device’ when I haven’t created one. -
Using F result for get key
I have dict like {product_id: count}. For example cart_items = {1: 150}. This dict represents customer basket. I also have product model with count field. It's representing stock balances. I want to get products that is in dict and update their quantity according to values in dict. I get products like this : products = Product.objects.filter(id__in=cart_items) And I want to update the quantity like this: products.update(count=dict.get(F("id")) But it doesn't work. Thx! -
hy,im beginner in django- error acqures regularly like this"Could not find 'Price' Did not find price on detailage" cld someone pls hlp me this
enter image description here my ad_detail.html in django-using pythonanywhere {% extends "base_menu.html" %} {% block title %}{{ settings.APP_NAME }}{% endblock %} {% load humanize %} <!-- https://docs.djangoproject.com/en/3.0/ref/contrib/humanize --> {% block content %} <span style="float: right;"> ({{ ad.updated_at|naturaltime }}) {% if ad.owner == user %} <a href="{% url 'ads:ad_update' ad.id %}"><i class="fa fa-pencil"></i></a> <a href="{% url 'ads:ad_delete' ad.id %}"><i class="fa fa-trash"></i></a> {% endif %} </span> <h1>{{ ad.title }}</h1> <p> {{ ad.text }} </p> <p> {{ ad.price }} </p> <p> <input type="submit" value="All Ads" class="btn btn-primary " onclick="window.location.href='{% url 'ads:all' %}';return false;"> </p> {% endblock %} my views.py from ads.models import Ad from ads.owner import OwnerListView, OwnerDetailView, OwnerCreateView, OwnerUpdateView, OwnerDeleteView class AdListView(OwnerListView): model = Ad class AdDetailView(OwnerDetailView): model = Ad fields = ["title", "text", "price"] class AdCreateView(OwnerCreateView): model = Ad fields = ["title", "text", "price"] class AdUpdateView(OwnerUpdateView): model = Ad fields = ["title", "text", "price"] class AdDeleteView(OwnerDeleteView): model = Ad it shows "could not price in detail"...im begginer just started to learn django someone pls help me on this -
telegram bot using python-telegram-bot django
I have a Telegram bot using the python-telegram-bot library and Django. The bot is run and messages are processed via a webhook pythonanywhere. I used the free plan and the bot was working perfectly, but I needed to upgrade the account to access external sites. After upgrading to the Hacker plan, issues started occurring with message processing and improper tracking. How can I resolve this issue? Could it be related to high CPU usage or SSH settings? Thank you. .................... -
Axios Error. IDE only do underline at 'corsheaders'. Typo: In word 'corsheaders'
Environment: Mac OS m2. Framework : Django, Vue. IDE : PyCharm. Library : opencv-python==4.6.0.66. mediapipe-silicon==0.8.10.1. keras==2.9.0. keras-tuner==1.1.3. tensorflow-macos==2.15.1. numpy==1.23.3. scikit-learn==1.1.2. pandas==1.4.3. matplotlib==3.6.0. seaborn==0.12.0. yellowbrick==1.5. Django==4.2.13. djangorestframework==3.14.0. django-cors-headers==3.13.0. django-extensions==3.2.1. protobuf==3.20. Hello, Hi, I'm studying with using someone else's repository regarding pose detection. I haven't been able to fix the issue for weeks regarding the axios network error. axios error in web(chrome). A network error occurs when I press the 'process' button that performs the core function. I mailed about the error to original author of repository, but didn't get answer. I looked it up a lot, and search it, then I found maybe it's a CORS-related problem, and the answers said me that the "If you write about the corsheader in settings, then the problem will solve". but that part has already been written. "corheaders" in settings. and others, "corheaders" in settings_2. "corheaders" in settings_3. While going through the code, I found that only 'corsheaders' are underlined on the IDE. wave underline only under "corsheaders". I thought maybe there's something wrong, so IDE don't recognize the corsheads and just judge it as a simple 'typo'. Is there anyone who can help with this? It's urgent because it's related to my university … -
Google OAuth 2.0 redirect_uri_mismatch
I'm getting a Google OAuth 2.0 redirect_uri_mismatch error. I receive this error when I add https://domain-name.com and https://domain-name.com/oauth/complete/google-oauth2/, but I can log in with Google when I run these URLs locally (http://127.0.0.1:8000 and http://127.0.0.1:8000/oauth/complete/google-oauth2/). Is there a mistake I might be missing? (Note: I'm using the Python Django library) Btw: Verification Status Verification in progress The Trust and Safety team has received your form. They will reach out to you via your contact email if needed. The review process can take up to 4-6 weeks. Expect the first email from our Trust and Safety team within 3-5 days. Your last approved consent screen is still in use I've tried to resolve the issue by ensuring that the redirect URIs specified in the Google Developer Console match those used in my Django application settings. I've also verified that the URIs are correct for both the production server and the local development environment. Additionally, I've double-checked the client ID and client secret provided to ensure they are accurate. Despite these efforts, I'm still encountering the redirect_uri_mismatch error. I expected that configuring the redirect URIs correctly would resolve the issue, but it persists. -
cookies are not being set django dont know why
Good afternoon i will continue here my old post, I have a small problem, I have 2 different functions and then I can share them, but in my code what is happening is that one of these lines of code works, and the other doesn't, and I really wanted to know why , because I wanted to insert a uuid in the cookies, but it didn't, just another way, here it goes: something like, this one works: response.set_cookie('user_uuid', str(face_recognition.uuid)) but this one no response.set_cookie('user_uuid', str(cookie_uuid)) why ? no idea, they have the same value and the same name, one insert , and the other one no the code that doesn't work def unique_identifier(request): print("unique identifier function called...") response = HttpResponse("Cookie Set") cookie_uuid = uuid.uuid4() # Create a UUID response.set_cookie('user_uuid', str(cookie_uuid)) print("UUID defined in the user's cookies:", cookie_uuid) return response debug: No UUID found in user cookies created a new UUID. unique identifier function called... UUID defined in user cookies: 5abb1b89-1ded-4fec-849d-567a9fb12d92 <django.contrib.sessions.backends.signed_cookies.SessionStore object at 0x000001A860C7BA50> Session key: None [22/May/2024 12:35:02] "GET / HTTP/1.1" 200 2373 the code that work @csrf_exempt def process_frame(request): print("Processando frame...") if request.method == 'POST': frame_data = request.POST.get('frame_data') frame_data = frame_data.split(',')[1] # Remover o prefixo 'data:image/png;base64,' frame_data = … -
How do I add 30-minute intervals to the django-grapelli TimeField?
I would like to add 30-minute time intervals instead of the default 1-hour intervals as seen from the screenshot below: screenshot I have tried asking ChatGPT, but the answers were unhelpful. Thank-you in advance. -
Get all Properties along with their allowed_tenants in a single query. Django and React
I have two models Property and Tenants. Each Property can have multiple allowed_tenants. Models I want a query where it fetches all properties along with their allowed_tenants in a single query(possibly less number of queries) using django orm class Tenants(models.Model): tenant_type = models.CharField(verbose_name='tenant type', max_length=32) def __str__(self): return self.tenant_type class Property(models.Model): owner = models.ForeignKey('user.User', on_delete=models.CASCADE, related_name='properties') property_name = models.CharField(verbose_name='property name', max_length=64) category = models.CharField(verbose_name='category', choices=Choices.category_choices, max_length=16) bathrooms = models.IntegerField(verbose_name='bathrooms', default=1) region = models.ForeignKey(Area, unique=True, related_name='properties', on_delete=models.CASCADE) # area = models.CharField(verbose_name='area', max_length=128) landmark = models.CharField(verbose_name='landmark', max_length=32) expected_rent = models.CharField(verbose_name='expected rent', default='not disclosed', max_length=16) expected_deposit = models.CharField(verbose_name='expected deposit', default='not disclosed', max_length=16) available_from = models.DateField(verbose_name='available from', default=datetime.date.today) allowed_tenants = models.ManyToManyField(Tenants, related_name='properties') likes = models.IntegerField(verbose_name='like', default=0) last_updated = models.DateField(verbose_name='last updated', auto_now_add=True) The result i am expecting should be like => [{...property_details, tenants: ['family', 'bachelor'], property_name: 'property1'}, {...}] i tried something like this, but its giving me multiple records for a single property with different tenants in each property properties = Property.objects.filter(allowed_tenants__tenant_type__in=['family']).annotate( property_owner=F('owner__first_name'), city=F('region__city__city'), area=F('region__area_name'), tenants=F('allowed_tenants__tenant_type'), ).values( 'property_owner', 'property_name', 'category', 'bathrooms', 'city', 'area', 'landmark', 'expected_rent', 'expected_deposit', 'available_from', 'tenants', 'likes', 'last_updated' ) [{...property1, tenants: 'family', property_name:'property_1'}, {...property1, tenants: 'bachelor', property_name:'property_1'}, {...}] -
trigger an action when a specific field is changed in Django models
I needs to change the OTP_expire value whenever OTP field change it's value class Account(AbstractBaseUser, PermissionsMixin): name = models.CharField(max_length=60, null=True) username = models.CharField(max_length=30, unique=True) password = models.CharField(blank=True) OTP = models.IntegerField(null=True) OTP_expire = models.DateTimeField(null=True) For that I thought of creating a trigger, but I could not figure out how to identify if the OTP field has changed or if another field has changed. -
Django with Nginx and Cloudflare: "400 Bad Request" on Redirect
I'm integrating an Iranian Stripe-like bank gateway provider with my Django application. When a user completes a successful purchase, the gateway redirects them back to our website using a predefined redirect URL to finish the deposit process. However, some users encounter a "400 Bad Request" error (as shown in the screenshot below) when they are redirected back to our site. The error message indicates that "The plain HTTP request was sent to HTTPS port. Here is my Nginx configuration: server { listen 80 default_server; server_name _; return 301 https://$server_name$request_uri; } server { listen 8443 default_server ssl http2; listen [::]:8443 ssl http2; server_name mydomain.com; ssl_certificate /etc/nginx/ssl/mydomain.com.cer; ssl_certificate_key /etc/nginx/ssl/mydomain.com.cer.key; access_log /project/logs/nginx/access.log; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header X-Frame-Options SAMEORIGIN; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options nosniff; add_header Referrer-Policy strict-origin-when-cross-origin; location / { try_files $uri @proxy_api; } location @proxy_api { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; proxy_pass http://web:8000; } location /static/ { autoindex on; alias /project/app/staticfiles/; } location /logs { autoindex on; alias /project/logs; types { text/plain log; } } } Screenshot: -
Terminate(Revoke) a Celery Task in Eventlet Pool
I switched prefork pool to eventlet. In my case my termination method not more working and rising this error: django.db.utils.DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 139661231139648 and this is thread id 139661089517376. Using django-db as result backend. Termination Method: def terminate(self): """ Terminate a service with bot_code """ task_name = f"{self.bot_code}_instance" try: task = PeriodicTask.objects.get(name=task_name) task.enabled = False task.save() celery_task_id = TaskController.get_celery_task_id_by(search_field="task_name", search_value=task.task, status="STARTED") if celery_task_id: current_app.control.revoke(celery_task_id, terminate=True) return Response({'message': 'Task terminated successfully.'}, status=status.HTTP_200_OK) except PeriodicTask.DoesNotExist: return Response({'error': 'Task does not exist.'}, status=status.HTTP_404_NOT_FOUND) -
how to pre-fill an fields for authentication method on the swagger or test it interactive api using drf spectacular?
i need to pre-filled fields like username, password for authentication on drf spectacular i'm using the schema and the auth,and i need to pre fill the fields like : username:text, password:text but i didn't find any document for that: "auth": [{"Api-Key Auth": []}, {"Basic Auth": []}, {"JWT Auth": []}], i've tried to add on the auth like this, but still can see the fields empty: class KeycloakBasicAuthExtension(OpenApiAuthenticationExtension): target_class = "contrib.keycloak.auth.KeycloackBasicAuth" name = "Basic Auth" priority = 1 match_subclasses = True def get_security_definition(self, auto_schema): return { "type": "http", "scheme": "basic", "x-example": {"username": "test", "password": "test"}, } and even i've tried to add n Request Name on the schema, but i can still see the Request Name when deploy to the gitbook as None: class CheckoutSchema(ModelSchema): view_class = CheckoutCreateApiView post = { "summary": "Create a new Payment Transaction", "description": "Create a new Payment Transaction", "tags": [ "Checkout API", ], "operation_id": "create_payment_transaction_checkout", "methods": ["POST"], "request": get_checkout_serializer(name="CheckoutPOSTRequestSerializer"), "responses": { 201: get_checkout_serializer(name="CheckoutPOSTResponseSerializer"), 400: PolymorphicProxySerializer( component_name="ClientErrors", serializers=[ serializers.FieldErrorSerializer, serializers.NestedFieldErrorSerializer, serializers.GenericErrorMessage, ], resource_type_field_name=None, ), 401: serializers.GenericErrorMessage, 403: serializers.GenericErrorMessage, 404: serializers.GenericErrorMessage, 415: serializers.GenericErrorMessage, 423: serializers.GenericErrorMessage, }, "examples": [ OpenApiExample( "Create Payment Transaction Example", summary="create a new payment transaction request example", description="This example demonstrates how to send a complete … -
Django: Performing actions after an object is created or updated
I've got a model called EventMembership which determines whether someone is attending the event or not:- class EventMembership(models.Model): user = models.ForeignKey(User, related_name='eventmemberships') is_attending = models.BooleanField() I also have an EventFee model which is used to track the user's fees for events:- class EventFee(models.Model): user = models.ForeignKey(User, related_name='eventfees') amount = models.DecimalField() If a user is attending the event, they should have a fee for that event's price. If not, they should not have a fee. What is the best way for me to handle the creating, updating or deleting of these fees? I've seen a lot of people warn against using signals and I have had problems with signals in the past but they seem like the perfect solution. I suppose it's signals or override the save() method on the model, isn't it? But overriding the save() method would mean the fees get updated every time the model is saved which seems bad to me. Any other suggestions? Note: I'm using Django Rest Framework for this so these EventMemberships can be created, updated or deleted through that. But they can also be updated via a couple of other mechanisms, like a user deleting their account, for example - where all of … -
Hosting/Joining Zoom Video Sessions Across Web application in Django and Flutter SDKs
I have integrated the Zoom Video SDK in my web application using the Video Web SDK in JavaScript. I am having trouble hosting/joining a video session using the session name and passcode passed from the Flutter SDK, which is integrated for the Android platform. I am using the same Zoom Video SDK account with the same SDK key and secret, and sharing the session name between the two applications. Is it not possible to do it this way? Do I need to take care of anything else? -
Issues with Gunicorn Not Finding Modules on EC2 Instance
I have a Django application running on an EC2 instance (following this tutorial). When I start the server using python manage.py runserver, everything works fine. However, when I try to use Gunicorn to serve my application, I encounter errors indicating that many modules cannot be found. Here's what I have done so far: Installed Gunicorn and requirements in my virtual environment using. Activated my virtual environment. Verified that my wsgi.py file is correctly configured. My wsgi.py looks like this: python import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') application = get_wsgi_application() When i try to start the gunicorn I get errors like this: `ModuleNotFoundError: No module named 'myapp'` for example: `ModuleNotFoundError: No module named 'boto'` Then when i resolved that one im getting more and more Im using python 3.11 and the following libraries: django==3.2.10 setuptools<58.0.0 six==1.16.0 django-environ==0.4.0 whitenoise==3.2.2 django-braces==1.10.0 django-crispy-forms==1.11.0 django-model-utils==2.6 Pillow<10 # was 3.4.2 before Catlina update django-allauth==0.61.1 awesome-slugify==1.6.5 pytz==2019.3 django-redis==4.5.0 redis>=2.10.5 selenium==3.6.0 django-filter==23.5 django-widget-tweaks==1.4.1 dateparser==0.7.0 paramiko==2.4.0 django-background-tasks==1.2.5 PyPDF2==1.26.0 python-docx==1.1.0 docxtpl==0.16.7 mock==2.0.0 twocaptchaapi==0.3 XlsxWriter==1.2.7 reportlab==4.0.0 openpyxl==2.6.4 django_tables2==2.7.0 pymysql==1.1.0 django-elasticsearch-dsl==8.0 coverage==4.2 django-coverage-plugin==1.3.1 Sphinx==1.4.8 django-extensions==3.2.3 Werkzeug==0.11.11 django-test-plus==1.0.16 factory_boy==2.7.0 django-debug-toolbar==1.6 ipdb==0.13.13 pytest-django==3.0.0 pytest-sugar==0.7.1 requests_aws4auth==0.9 gunicorn==21.2.0 #must be in requirements.txt Dont really know why runserver works fine but not with gunicorn. Has …