Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django upload csv to DB via template with function
I made a function with "runscript" on Django. I wanna know how can I upload a CSV file via a template with my function. this is my function: def run(): df = pd.read_csv("scripts/Combination.csv", dtype=str) df = df[pd.isnull(df["id"])] def sub_budget_owner_found(v_BO, v_SBO): try: Employee.objects.get_or_create(name=v_BO) v_BO_obj = Employee.objects.get(name=v_BO) except: v_BO_obj = Employee.objects.get(name="99999 No Budget Owner") try: Employee.objects.get_or_create(name=v_SBO) v_SBO_obj = Employee.objects.get(name=v_SBO) except: v_SBO_obj = Employee.objects.get(name="99998 No Sub Budget Owner") return SubBudgetOwner.objects.get_or_create( budget_owner=v_BO_obj, sub_budget_owner=v_SBO_obj ) for i, row in df.iterrows(): v_subsidiary = row["Subsidiary"] v_department = row["Department"] v_account = row["Account"] v_sub_budget = row["Sub Budget"] v_budget_owner = row["Budget Owner"] v_sub_budget_owner = row["Sub Budget Owner"] Combination.objects.get_or_create( subsidiary=Subsidiary.objects.get_or_create(name=str(v_subsidiary))[0], department=Department.objects.get_or_create(name=str(v_department))[0], account=Account.objects.get_or_create(name=str(v_account))[0], sub_budget=SubBudget.objects.get_or_create(name=str(v_sub_budget))[0], budget_owner=sub_budget_owner_found(v_budget_owner, v_sub_budget_owner)[0], ) print(i, row) I use Django view classes. The purpose is to upload new data via CSV file in the GUI. Thanks a lot -
Issue with django, react and nginx server with docker
I am new with nginx and trying to understand how its works. I build and dockerize a website using react for the frontend and django for backend and serving both react and django api with nginx. But when I reach localhost which should serve react app, everything works well. The problem appear when I want to access for example localhost/docs or localhost/admin which should be serve by gunicorn and django. I always obtain bad request (400) In my settings.py I have ALLOWED_HOSTS = [] ALLOWED_HOSTS.extend( filter( None, os.environ.get('ALLOWED_HOSTS', '').split(' '), ) ) STATIC_URL = '/static/static/' MEDIA_URL = '/static/media/' MEDIA_ROOT = '/vol/web/mediafiles' STATIC_ROOT = '/vol/web/staticfiles' my .env file DB_NAME=dbname DB_USER=rootuser DB_PASS=dbpassword DJANGO_SECRET_KEY=secretkey_for_production_environment DJANGO_ALLOWED_HOSTS=localhost Here is docker-compose-prod.yml file version: "3.9" services: db: image: postgres:13-alpine container_name: db-prod-c restart: always volumes: - db-prod:/var/lib/postgresql/data environment: - POSTGRES_DB=${DB_NAME} - POSTGRES_USER=${DB_USER} - POSTGRES_PASSWORD=${DB_PASS} backend: build: context: ./backend dockerfile: Dockerfile.prod #restart: always image: api-prod-i:django-prod container_name: api-prod-c user: root volumes: - mediafiles:/vol/web/mediafiles - staticfiles:/vol/web/staticfiles environment: - DB_HOST=db - DB_NAME=${DB_NAME} - DB_USER=${DB_USER} - DB_PASS=${DB_PASS} - SECRET_KEY=${DJANGO_SECRET_KEY} - ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS} expose: - 8000 depends_on: - db # networks: # - django-network frontend: build: context: ./frontend dockerfile: Dockerfile #restart: always image: client-prod-i:django-prod container_name: client-prod-c volumes: - react-build:/frontend/build depends_on: - backend proxy: build: context: … -
Cannot upload images to S3 from Django backend and Nextjs frontend vercel
I have an e-commerce site built with Django and nextjs. Previously it was hosted on hostinger but recently I moved the API backend to AWS Lambda and the frontend to vercel. I'm storing the product images in S3. The problem I;m facing is after the migration, I'm not able to upload the images from my nextjs frontend. I have tried uploading the images from postman and Django admin panel and it worked. It just not works from the nextjs frontend. Here is the error: An error occurred (400) when calling the HeadObject operation: Bad Request I'm using django-storages to upload my images to S3. I'm using FormData to send images from frontend to backend. frontend submit function: function submit() { setIsLoading(true); var myHeaders = new Headers(); myHeaders.append("Authorization", `Bearer ${session?.token?.access}`); myHeaders.append("Cookie", "django_language=en"); var formdata = new FormData(); formdata.append("name", name); formdata.append("desc", desc); formdata.append("length", length); formdata.append("height", height); formdata.append("width", width); formdata.append("measure", measurements); formdata.append("origin", origin); formdata.append("signed", signed); formdata.append("reproduce", reproduce); formdata.append("reproduce_days", reproduce_days); formdata.append("image", img); formdata.append("reg_price", price); formdata.append("cat", category); formdata.append("year", year); formdata.append("newcat", otherCategory); formdata.append("newsubcat", otherSubCategory); formdata.append("newmedium", otherMedium); formdata.append("subcat", subCategory); formdata.append("medium", medium); formdata.append("orientation", orientation); formdata.append("stock_quantity", quantity); var requestOptions = { method: "POST", headers: myHeaders, body: formdata, redirect: "follow", }; fetch( `${API_URL}/profile/vendor/${session?.token?.user?.id}/add-product/?curr=INR`, requestOptions ) .then((response) => response.text()) .then((result) => … -
How i save multiple request.POST.get() in form.save()
I wanna get data with request.POST.get() and then save in form.save(). How i can solve that? def example(request): form = addform() if (request.method == 'POST'): form = addform(request.POST) question = request.POST.get('question') answer = request.POST.get('answer') explain = request.POST.get('explain') if (form.is_valid()): form.save() # i wann save all (question + answer + explain) here in form. context = {'form': form} return render(request, 'Example_fragenkatalog.html', context) I hope someone can help me! Thank you! -
Django bulk_create() with models' fields having custom validators
In my Django application, I am using bulk_create(). For one of the fields in a target model I have assigned a set of validators to restrict the allowed value to uppercase letters (alphabets) and to a fixed length of "3", as shown below: class Plant(models.Model): plant = models.CharField(primary_key=True, max_length=4, ... plant_name = models.CharField(max_length=75, ... plant_short_name = models.CharField(max_length=3, validators=[... # rest of the fields ... I am restricting field plant_short_name to something like CHT for say, Plant Charlotte. Using the source file (.csv) I am able to successfully create new instances using bulk_create, however I find that the data get saved even with field plant_short_name's value being different. For example, if I use the source as: plant,plant_name,plant_short_name 9999,XYZ Plant,XY the new instance still gets created although the length of (string) value of field plant_short_name is only 2 (instead of 3 as defined in the validators). If I am to use an online create function (say, Django CreateView), the validators work as expected. How do I control / rstrict the creation of model instance when a field value of incorrect length is used in the source file? -
deference between request.meta and request.headers In django
what is the deference between these ? I see in the django doc that we can get content-length in meta and header atrebute in HttpResponse class. so what is the difference between request.meta and request.headers? -
forward and backward in ajax
I have a page with products that are filtered through ajax. Also the url changes via pushState. But when you click the backward and forward buttons in the browser, nothing happens, only the url changes. How to handle the clicks of these buttons? -
How to extract two values from list in python?
I'm using python3 and and i have data set. That contains the following data. I'm trying to get the desire value from this data list. I have tried many ways but unable to figure out how to do that. slots_data = [ { "id":551, "user_id":1, "time":"199322002", "expire":"199322002" }, { "id":552, "user_id":1, "time":"199322002", "expire":"199322002" }, { "id":525, "user_id":3, "time":"199322002", "expire":"199322002" }, { "id":524, "user_id":3, "time":"199322002", "expire":"199322002" }, { "id":553, "user_id":1, "time":"199322002", "expire":"199322002" }, { "id":550, "user_id":2, "time":"199322002", "expire":"199322002" } ] # Desired output # [ # {"user_id":1,"slots_ids":[551,552,553]} # {"user_id":2,"slots_ids":[550]} # {"user_id":3,"slots_ids":[524,525]} # ] I have tried in the following way and obviously this is not correct. I couldn't figure out the solution of this problem : final_list = [] for item in slots_data: obj = obj.dict() obj = { "user_id":item["user_id"], "slot_ids":item["id"] } final_list.append(obj) print(set(final_list)) -
Access Foreign Key count in Django Template
I have two models: Farm and Animal with a ForeignKey relation. Each Farm contains x animals. I'm doing a table in the frontend with a for loop of each farm. How can I show the number of animals in each farm? models: class Farm(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True, default=None) square_meter = models.IntegerField(blank=True, null=True) friendly_name = models.CharField(max_length=24, blank=True) kml = models.FileField(upload_to=user_directory_path_kml, null=True, blank=True) class Animal(models.Model): class Meta: verbose_name_plural = "Animals" farm = models.ForeignKey(Farm, on_delete=models.CASCADE, blank=True, null=True, default=None) name = models.CharField(max_length=24, blank=True) datetime = models.DateTimeField(blank=True, null=True, default=datetime.now) tracking = models.BooleanField(default=False) kg = models.IntegerField(blank=True, null=True) template: {% for farm in farms %} <tr> <th scope="row">{{forloop.counter}}</th> <td>{{farm.friendly_name}}</td> <td>{{farm.square_meter}}</td> <td>{{farm. }}</td> # Here I want animal count </tr> {% endfor %} -
How to call HTML page as a popup from another HTML page using Django
I am working on Django project where i need pop up the HTML when i click the button. Let me explain, when ever user click the button it should open another HTML as a popup there user can upload the files and download the sample files. Could you please help me on the issue Here is my code below, HTML Button - <button data-href='{% url "employeeBulkUpload" companydetail.id %}' id="uploadEmployees" title="Upload Employees" class="btn btn-blue mr-2 px-3 d-block w-100 text-95 radius-round border-2 brc-black-tp10"><i class="fa fa-upload"></i></button> $(document).ready(function () { $('#uploadEmployees').initDialog({'url': '{% url "employeeBulkUpload" companydetail.id %}', 'title': 'Upload Employees'}); }); -
How to display related One to Many Instances in ListView?
I want to display all belonging Instances of model Report referenced to model Module referenced to model Course. Therefore I implemented three Models related via Foreignkey. class Course(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) title = models.CharField(max_length=200, blank=True, null=True) class Module(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) title = models.CharField(max_length=200, blank=True, null=True) course_id = models.ForeignKey( Course, null=True, on_delete=models.SET_NULL, related_name="modules", default=uuid.uuid4, ) class Report(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) title = models.CharField(max_length=200, blank=True, null=True) module_id = models.ForeignKey( Module, null=True, on_delete=models.SET_NULL, related_name="reports", default=uuid.uuid4, ) I want to display model Module referenced to model Course in CourseDetailView(DetailView): Here is what I implemented: class CourseDetailView(DetailView): model = Course context_object_name = "course" template_name = "course/course_detail.html" fields = ["title", "description"] def get_context_data(self, **kwargs): context = super(CourseDetailView, self).get_context_data(**kwargs) context["courses"] = Course.objects.filter(pk=self.kwargs.get("pk")) return context and I get the instance belonging to itsself. If I change the context to: context["modules"] = Module.objects.all() and iterate over modules in course_detail.html: {{ course.description|safe }} {% for module in modules %} <div> <h2><a href="{{ module.get_absolute_url }}">{{ modules.title }}</a></h2> </div> {% endfor %} I'll get all instances of Module but I want only the ones related to the specific Course. I know I have to filter context["modules"] but I don't know how to do it. Due … -
Creating Integer Range from multiple string math expressions in python
I have a problem in a project and I've searched the internet high and low with no clear answer. How can i convert math expressions As 3x + 5y >= 100 And x,y < 500 Into a range of x and range of y to be used as ristriction in a math problem, Ex: f = x^2+4y The end result is to find the largest answer using genetic algorithms where x and y are ristricted in value. Tried sympy and eval with no luck Searched every and found only a few helpful but not enough resources I need just to translate the user input to the code for the genetic algorithm to use. -
Django admin upload multiple images in 1 form
I dont want to use inlines so I figured I want to upload a bunch of images at the same time. Now I've been struggling for an entire day to get it working but it doesn't for some reason. My first code: Model class LaptopInfoImages(models.Model): laptop_info = models.ForeignKey(LaptopInfo, on_delete=models.CASCADE) image = models.ImageField(upload_to=images_directory) admin class LaptopInfoImagesForm(forms.ModelForm): image = forms.ImageField(widget=forms.ClearableFileInput(attrs={'multiple': True})) class Meta: model = LaptopInfoImages fields = '__all__' def save(self, commit=True): instance = super().save(commit=False) for image in self.cleaned_data['image']: image_obj = LaptopInfoImages(laptop_info=instance.laptop_info, image=image) image_obj.save() if commit: instance.save() return instance This gives me the error: AttributeError: 'bytes' object has no attribute '_committed' So I changed the code to: admin class LaptopInfoImagesForm(forms.ModelForm): image = forms.ImageField(widget=forms.ClearableFileInput(attrs={'multiple': True})) class Meta: model = LaptopInfoImages fields = '__all__' def save(self, commit=True): instance = super().save(commit=False) for image in self.cleaned_data['image']: # Convert the image to a BytesIO object bytes_io = BytesIO(image) # Create an InMemoryUploadedFile from the BytesIO object in_memory_file = InMemoryUploadedFile( bytes_io, None, 'image.jpg', 'image/jpeg', len(image), None ) # Save the image to the LaptopInfoImages model image_obj = LaptopInfoImages(laptop_info=instance.laptop_info, image=in_memory_file) image_obj.save() if commit: instance.save() return instance It doesnt give me any errors but it is uploading 9332 laptop info imagess and the images don't work. -
How to clean and save multiple instances one after one in Django using clean and save methods?
I noticed that when using Django admin and whenever select/change multiple instances and click on save button (for example see the below image, it's not directly related to the code below), Django will clean/validate all instances and then save them one by one. is this how things are working in Django or the process should be clean and then save the instance before repeat same process with the next instance? because when trying to set is_active value to be true for multiple instances, it passing the clean method condition without shown the error message that tells should only one instance be selected as true and that's correct cause no one of the instances have is_active as true in the database yet But if I click the save button again will show the error message. models.py: class SupplierAddress(models.Model): """Model to create supplier's address instances""" class Meta: """Customize django default way to plural the class name""" verbose_name = 'Supplier Address' verbose_name_plural = 'Supplier Addresses' constraints = [ models.UniqueConstraint( fields=['supplier', 'address'], name='supplier_address_unique_appversion' ) ] # Define model fields. supplier = models.ForeignKey( 'Supplier', on_delete=models.CASCADE, related_name='supplier_addresses_supplier' ) address = models.ForeignKey( 'Address', on_delete=models.CASCADE, related_name='supplier_addresses_address' ) is_active = models.BooleanField(default=False) def clean(self): """Restrict the add/change to model fields""" … -
Multi Nested Serializers in django
Nested Serializers is not working properly... { "book_id": 1, "book_name": "AAAA", "language": "A", "category_type": "a", "page_count": 212, "price": "212.00", "volume": 1, "year_of_publication": "2022-12-08", "rating": 2, "cover_image": "http://127.0.0.1:8000/media/images/download_1_8Bvr7hM.jpg", "pdf": "http://127.0.0.1:8000/media/pdf/eclipse_path_mUBp1xX.txt", "Author": [ { "publisher_id": 1, "publisher_name": "pub2we", "created_at": "2022-12-21T11:37:26.192207Z", "updated_at": "2022-12-21T11:37:26.192207Z" "PUblisher" :[ { "publisher_id": 1, "publisher_name": "pub2we", "created_at": "2022-12-21T11:37:26.192207Z", "updated_at": "2022-12-21T11:37:26.192207Z" }, ] }, ] }, [ enter image description here] (https://i.stack.imgur.com/0A6tZ.png) -
How to inline radio buttons in a django form?
Here's the radio buttons: account_type = forms.ChoiceField( choices=enumerate(('Choice 1', 'Choice 2')), widget=forms.RadioSelect( {'class': 'form-check form-check-inline', 'style': 'margin-left: 20px'} ), label='', ) I'm using bootstrap-nightshade for styling which possibly contains something that prevents inlining the buttons. So far I tried: display: inline and display: inline-block; and class="radio-inline" Nothing works. Here's the template of the form {% extends 'index.html' %} {% load bootstrap5 %} {% block content %} <section class="h-100"> <div class="container h-100"> <div class="row justify-content-sm-center h-100"> <div class="col-xxl-4 col-xl-5 col-lg-5 col-md-7 col-sm-9"> <div class="card shadow-lg"> <div class="card-body p-5"> <h4>{{ form_title }}</h4> <form method="post"> {% csrf_token %} {% bootstrap_form form %} <button class="btn btn-success">{{ form_title }}</button> {% if form_title == 'Sign in' %} <a style="margin-left: 15px" href={% url 'reset-password' %}>Forgot password?</a> {% endif %} </form> </div> </div> </div> </div> </div> </section> {% endblock %} -
PycharmProjects\pythonProject\vencannot be loaded because running scripts is disabled on this system. For more informatio see about_Execution_Policies
I want to install Django on pycharm but when I try to install this massage display: File C:\Users\dell\PycharmProjects\pythonProject\venv\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. + CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnauthorizedAccess -
admin profile view after login instead of displaying user profile in django
I am working on a django project.There are two types of users. One is admin and another one is researcher. So I want to display admin profile when admin logs in using the login page instead of researcher profile. I know django has an admin panel. But I want to build custom admin profile. So when admin logs in using the login page created by myself, admin can see the posts created by users. Also he can add category, approve post, delete post. On the other hand, when researchers logs in, users can see their profile page. blog/models.py from django.db import models from django.utils import timezone from django.contrib.auth import get_user_model from django.urls import reverse from ckeditor.fields import RichTextField # Create your models here. class Category(models.Model): cid = models.AutoField(primary_key=True) category_name = models.CharField(max_length=100) def __str__(self): return self.category_name class Post(models.Model): aid = models.AutoField(primary_key=True) image = models.ImageField(default='blog-default.png', upload_to='images/') title = models.CharField(max_length=200) content = RichTextField() created = models.DateTimeField(default=timezone.now) author = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) cid = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='specialization') approved = models.BooleanField('Approved', default=False) like = models.ManyToManyField(get_user_model(), related_name='likes', blank=True) def __str__(self): return self.title users/model.py from django.db import models from blog.models import Category from django.contrib.auth.models import AbstractUser # Create your models here. class CustomUser(AbstractUser): cid = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='specialization', … -
Periodically create/update a model based on another model's annotation
I have model Foo that changes periodically (every week for simplicity). The corresponding API endpoint for this model only needs the annotation foo_annotate. I want to be able to backtrack even if the period changes. My current setup works fine but I realized that if new entries are created in the database, I may run out of storage. So instead of doing that, I create a new model based on the computed value from Foo. Here's what I have so far: class FooManager(models.Manager): ... def get_queryset(self): return super(FooManager, self).get_queryset() \ .annotate(foo_annotate=Coalesce(models.Count("bar"), 0)) # Annotation is much more complex class Foo(models.Model): # Periodic model ... period = models.CharField(...) # Name of current period, unsure if DateField is better user = models.ForeignKey(User, ...) objects = FooManager() class Bar(models.Model): # Fields may change ... foo = models.ForeignKey(Foo, ...) class Baz(models.Model): # Model based on annotation period = ... foo_annotate = ??? -
cannot import name 'urlquote' from 'django.utils.http'
I am trying to login to the admin portal, however I am getting the below error. Please help I have been searching for solution but nothing Exception Type: ImportError at /admin/login/ Exception Value: cannot import name 'urlquote' from 'django.utils.http' (C:_project\my-events\env\lib\site-packages\django\utils\http.py) -
Postgresql cannot connect to server
The project is a django web app, packed on docker containers. For some reason, I cannot run the server and launch it. when I run "manage.py runserver", this error occurs: File "C:\Users\andre\AppData\Local\Programs\Python\Python310\lib\site-packages\psycopg2\__init__.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) django.db.utils.OperationalError: connection to server at "158.160.17.21", port 5432 failed: Connection refused (0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections? What do you think can be done with it? Thank you. -
django.db.backends.postgresql
I am trying to switch my Django database from SQLite3 to PostgreSQl, so I follow many tutorials to install and setup Postgres with Django project. I do the following: pip install psycopg2, pip install psycopg2-binary and I modify the settings.py like that: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': BASE_DIR / 'db.postgresql', 'USER': 'muusername', 'PASSWORD': 'mypassword', 'HOST': '127.0.0.1', 'PORT': '5432' } } Finally I make my database, by running the command python manage.py makemigrations. However, I got this error: django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in backends, use 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'sqlite3' Please note that I am also seccesufully install the pgAdmin in my OS which is Windows 10. I know that the problem is postgres is not configured in my django project, but I don't know how to add it, also I check my djnago version which is tha latest one, also all needed packages are installed in venv. -
Deploy django/react on the same server, different port?
I have 2 projects for backend and frontend which are written in django and react respectively. I bought one linux server, now I'm wondering is it possible to deploy these two projects in one server? (in different ports), if so, how? To be honest, I can't find any good articles about this. I have an experience deploying only django projects using linux/apache... -
Polygon selection based on marker position in leaflet
On the map, I have an added layer with polygons and one marker on another layer. When I click anywhere, the marker moves to that location and the polygon is selected. The marker has the ability to drag across the map, but just when I drag it, the polygon selection does not appear. How to do this? var osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }); var map = new L.Map('map', { 'center': [51, 17], 'zoom': 6, 'layers': [osm], }); var selected; var marker marker = L.marker([51, 17], { draggable: true }).addTo(map); var geoJsonLayer2 geoJsonLayer2 = L.geoJson( polygons ,{ style: { fillColor: "#1ED100", color: "orange", fillOpacity: 0.0, opacity: 0.0, }, }) .on('click', function (e) { // Check for selected if (selected) { // Reset selected to default style e.target.resetStyle(selected) } // Assign new selected selected = e.layer // Bring selected to front selected.bringToFront() // Style selected selected.setStyle({ 'color': 'red', 'opacity': 1, }) }) .addTo(map); marker.on('dragend', function (e, feature) { updateLatLng(marker.getLatLng().lat, marker.getLatLng().lng); }); map.on('click', function (e) { marker.setLatLng(e.latlng); updateLatLng(marker.getLatLng().lat, marker.getLatLng().lng); }); function updateLatLng(lat, lng, reverse) { if (reverse) { marker.setLatLng([lat, lng]); map.panTo([lat, lng]); } else { document.getElementById('lat').value = marker.getLatLng().lat.toFixed(10); document.getElementById('long').value = marker.getLatLng().lng.toFixed(10); map.panTo([lat, lng]); document.getElementById("lat").value = lat.toFixed(10); document.getElementById("long").value = … -
ModuleNotFoundError: No module named 'application' when deploying Django app to AWS EB
I'm trying to deploy a django project to Elastic Beanstalk. I have the following code in .ebeextensions/django.config option_settings: aws:elasticbeanstalk:container:python: WSGIPath: pos.wsgi:application aws:elasticbeanstalk:application:environment: DJANGO_SETTINGS_MODULE: pos.settings I see this error all the time in the logs ModuleNotFoundError: No module named 'application' I've tried to write the config file this way, but still the same error option_settings: aws:elasticbeanstalk:container:python: WSGIPath: pos/wsgi.py Here is the platform Python 3.8 running on 64bit Amazon Linux 2/3.4.2