Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
All users share the same data created, how do i fix it?
I made a program where users put their expenses to keep track of them, after they create their own account. But when i test it, all users share the same table. Ex: Lets say user 1, add to the table "Rent: $2500", but when i close that account and open a new one (User 2), i can see the expenses of the other Users in the page. Please help me, I've been putting a lot of time trying to solve it but i cant. Thanks in advance Model: class Customer(models.Model): user = models.OneToOneField(User, null=True, on_delete=models.CASCADE) name = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200, null=True,blank=True) date_created = models.DateTimeField(auto_now_add=True, null=True) # def __str__(self): # return self.name (i don't now if it's correct) class Finance(models.Model): expenses_category = [ ("Saving", "Saving"), ("Food", "Food"), ("Bills", "Bills"), ("Rent", "Rent"), ("Extra", "Extra"), ] expenses_month = [ ("January", "January"), ("February", "February"), ("March", "March"), ("April", "April"), ("May", "May"), ("June", "June"), ("July", "July"), ("August", "August"), ("September", "September"), ("October", "October"), ("November", "November"), ("December", "December"), ] customer = models.ForeignKey(User, on_delete=models.CASCADE, null=True,blank=True) category = models.CharField(choices=expenses_category, max_length=200) price = models.IntegerField() month = models.CharField(choices=expenses_month, max_length=200) Views: @csrf_exempt def registerPage(request): if request.user.is_authenticated: return redirect('home') else: form = CreateUserForm() if request.method == 'POST': form = CreateUserForm(request.POST) if form.is_valid(): … -
django.db.utils.NotSupportedError: PostgreSQL 12 or later is required (found 11.19)
I am getting this error when I try to run my django server locally: "django.db.utils.NotSupportedError: PostgreSQL 12 or later is required (found 11.19).". The local django server is connected to a postgres instance hosted on ElephantSQL. I have installed psycopg2-binary==2.9.6. But when I run "python manage.py runserver", I get the error "django.db.utils.NotSupportedError: PostgreSQL 12 or later is required (found 11.19).". I tried upgrading my computer's postgres with homebrew, up to 12.5. This did not fix the problem, as I still get the same error (which still mentions 11.19). I do not know what instance of postgres this 11.19 refers to, and how to update it to 12 or above. Ideas? Note- another stack overflow post about this suggested downgrading my django version from a 4 to a 3, but this seems like a bad way to fix it. -
Upload file in django plotly don't working
I build a module to analyze a file and return a plotly graphic. Now i need to implement im django template, but can't integrate a upload file in my plotly module. I can make the upload and the function it's working, but i can't using together. The situation is: I need a to upload a file, make the analyze with a plotly function and return a graphic. This is my django view code: def test_page(request): directory = 'C:\\tmp\\Uploads\\' if request.method == 'POST': upload_file = request.FILES['document'] fs = FileSystemStorage(location=directory) filename = upload_file.name url = fs.url(upload_file) file = directory + filename print(file) #plotly function UFLGplots = visualization_Django_Dash.build_GRplots(file) context = { 'UFLGplots': UFLGplots, } return render(request, 'index.html', context) When i make the runserver the firt error is The varible file is empty. I want to call the plotly function just when i make the upload file. -
Is it possible to specify a foreign key for a table field in Django models.py to any table from the database?
Suppose there is a table in the database "table", not created by Django. Is it possible to specify it as a foreign key in any way? class Object(models.Model): object_id = models.IntegerField(unique=True) param = models.ForeignKey('table', on_delete= models.DO_NOTHING) ... -
The 'mainimage' attribute has no file associated with it. While sending a signal
I'm trying to send a signal when the post is created like this @receiver(post_save, sender=Post) def new_post_saved(sender, instance, created, **kwargs): if created: user = instance.author user_id = instance.author.id post_id = instance.id post_title = instance.title post_content = instance.content post_mainimage = instance.mainimage.url if instance.mainimage else None # Check if mainimage has a file associated with it post_rpfile = instance.rpfile if instance.rpfile else None post_version = instance.version post_xnumber = instance.xnumber post_category = instance.category post_date = instance.date_added post_likes = instance.likes.count() webhook_url = "" session = requests.Session() webhook = SyncWebhook.from_url(webhook_url, session=session) # To send a message e = discord.Embed(title=f"{post_title}", description=f"{post_content}", color=discord.Color.from_rgb(255, 0, 0)) e.add_field(name='Download', value=f"[Click here](https://my-project.mrahmed2.repl.co/{post_rpfile})") e.add_field(name="likes", value=f"{post_likes}") e.add_field(name="version", value=f"{post_version}") e.add_field(name='x number', value=f"{post_xnumber}") e.set_image(url=f"https://my-project.mrahmed2.repl.co/{post_mainimage}") e.set_footer(text=f'{post_date}') webhook.send(embed=e) but i get this error The 'mainimage' attribute has no file associated with it. and the mainimage has no file associated with it becouse i use this function on my image filed def thumbnail_upload_to(instance, filename): return f'resourepacks/{instance.id}/images/thumbnail/{filename}' and of course i use save function to update those two fileds after the post is created so the instance.id in the thumbnail_upload_to function not = None **so my path will be ** ------resourepacks -----------1 ----images -thumbnail -test.jpg my save function def save(self, *args, **kwargs): if self.pk is None: saved_image = self.mainimage … -
How to assign an order to field in a many to many field
This is my first django project so I'm still learning. I Django project of Formula One Races and Racers. The Race model looks like this, class Race(models.Model): name = models.CharField(max_length=250) location = models.CharField(max_length=250) date = models.DateField() track = models.URLField() comments = models.TextField() @property def has_passed(self): return self.date < date.today() class Meta: ordering = ["date"] def __str__(self): return self.name and the racers look like this, class Players(models.Model): name = models.CharField(max_length=250) country = models.CharField(max_length=250) team = models.ForeignKey( Teams, related_name = "players_team", on_delete = models.CASCADE ) races = models.ManyToManyField( Race, related_name= "results", ) class Meta: ordering = ["name"] def __str__(self): return self.name I want to be able to assign a different order to the racer for each race to show the race results. How would I be able to assign this order? Thank you I tried to manually assign ordering on by creating a result model, I feel like that is clunky. -
When using Router in react its not showing data from database but without Router its working
When using Router in react its not showing data from database but without Router its working But when router with defined function in routes.js its not showing data from server side App.js import React, {Component} from 'react'; import { BrowserRouter as Router} from 'react-router-dom'; import BaseRouter from './routes'; import 'antd/dist/reset.css'; import CustomLayout from './container/layout'; // import ArticleList from './container/ariclelistview'; //not working class App extends Component{ render(){ return( <div className='App'> <Router> <CustomLayout> <BaseRouter/> </CustomLayout> </Router> </div> ); } } // working // class App extends Component{ // render(){ // return( // <div className='App'> // <CustomLayout> // <ArticleList/> // </CustomLayout> // </div> // ); // } // } export default App; routes.js import React from "react"; import ArticleList from './container/ariclelistview'; import { Route } from 'react-router-dom'; const BaseRouter = () => { <div> <Route exact path ='/' Component={ArticleList} /> <Route exact path ='/:articleID' Component={ArticleList} /> </div> }; export default BaseRouter; ArticleList.js import React from "react"; import Articles from "../components/articles"; import axios from 'axios'; const data = Array.from({ length: 23, }).map((_, i) => ({ href: 'https://ant.design', title: `ant design part ${i}`, avatar: `https://xsgames.co/randomusers/avatar.php?g=pixel&key=${i}`, description: 'Ant Design, a design language for background applications, is refined by Ant UED Team.', content: 'We supply a series … -
How to generate a fake HTTP request object for unit test in Python?
In a Python Django project, we want a unit test to feed a HTTP POST request into the function under test. The cURL sample command below shows our test settings. The cURL approach starts from the web server's endpoint and triggers the entire logic path, but we want the unit test to focus on a specific function taking in the request argument. And, we got hint from this post with the below sample Python source code to fake a HTTP request for testing. Our Question: See the -d argument of the cURL command, we wonder how to feed the request body in the faked object. Technical Details: The cURL command: curl http://127.0.0.1:8000/api/transaction/ --insecure \ --verbose \ -d '<env:Envelope ... > <env:Header> ... </env:Header> <env:Body> ... </env:Body> </env:Envelope> ' The Python sample source code for faking a HTTP request: from django.core.handlers.wsgi import WSGIRequest from io import StringIO from django.contrib.auth.models import AnonymousUser def GetFakeRequest(path='/', user=None): """ Construct a fake request(WSGIRequest) object""" req = WSGIRequest({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': path, 'wsgi.input': StringIO()}) req.user = AnonymousUser() if user is None else user return req -
NGINX Django DRF Vue.js POST method returns Method Get not allowed 405
I am building an ecommerce site. Everything works well, except the forms. When I try to post something, it returns me 405 method get not allowed. Why is it giving GET error when I am trying to do POST? It works on some forms, like for example checkout. But when I try to use contact form and press send axios.post('/api/v1/contacto/', data) it gets me this error 405. BTW, when I am using this e-commerce running it on my local machine, it works well. Here is my sites-available: upstream ecologic_app_server { server unix:/webapps/ecologic/backend/venv/run/gunicorn.sock fail_timeout=0; } server { listen 8000; listen [::]:8000; server_name myiphere; client_max_body_size 40M; location / { root /webapps/ecologic/frontend; try_files $uri /index.html; index index.html index.htm; } location /static/ { root /webapps/ecologic/backend; } location /media/ { root /webapps/ecologic/backend; } location /api/v1/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_set_header Host $http_host; proxy_pass http://ecologic_app_server/api/v1/; proxy_ssl_session_reuse off; proxy_redirect off; } location /admin/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_pass http://ecologic_app_server/admin/; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_redirect off; } } This is my urls.py: from django.urls import path, include from . import views urlpatterns = [ path('contacto/', views.contact_form_post), path('reclamo/', views.complaints_form_post), ] Here is my code for contact … -
Django rest framework post data not being serialized properly
I have 2 models class MenuItem(models.Model): title = models.CharField(max_length=255, db_index=True) price = models.DecimalField(max_digits=6, decimal_places=2, db_index=True) featured = models.BooleanField(db_index=True) category = models.ForeignKey(Category, on_delete=models.PROTECT) def __str__(self): return f'{self.title}' class Cart(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) menuitem = models.ForeignKey(MenuItem, on_delete=models.CASCADE) quantity = models.SmallIntegerField() unit_price = models.DecimalField(max_digits=6, decimal_places=2, default=0) price = models.DecimalField(max_digits=6, decimal_places=2, default=0) class Meta: unique_together = ('menuitem', 'user') The MenuItem.price should be equal to Cart.unit_price for a particular object. Now the problem I'm having is writing the serializer for the Cart Model. So far I've tried this: class MenuItemSerializer(serializers.HyperlinkedModelSerializer): title = serializers.CharField(max_length=255) price = serializers.DecimalField(max_digits=6, decimal_places=2) category_id = serializers.IntegerField(write_only=True) category = CategorySerializer(read_only=True) featured = serializers.BooleanField() class Meta: model = MenuItem fields = ['title', 'price', 'category', 'category_id', 'featured'] depth = 1 class CartSerializer(serializers.ModelSerializer): user = serializers.HiddenField( default=serializers.CurrentUserDefault(), ) menu_item = MenuItemSerializer quantity = serializers.IntegerField() # unit_price = serializers.DecimalField(max_digits=6, decimal_places=2, style={'input_type':'hidden'}) unit_price = serializers.ReadOnlyField(source="menuitem.price", read_only=True) price = SerializerMethodField() class Meta: model = Cart fields = ['user', 'menuitem', 'unit_price', 'quantity', 'price'] def get_price(self, obj): return obj.quantity * obj.unit_price and then the relevant view class Cart(mixins.ListModelMixin, mixins.DestroyModelMixin, generics.GenericAPIView): queryset = Cart.objects.all() serializer_class = CartSerializer def get(self, request, *args, **kwargs): return self.list(request, *args, **kwargs) def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) def … -
django duplicate SQL queries stemming from model method get_absolute_url that accesses ForeignKey relationship
Problem Summary I have a class-based list view that just displays links for each object along with some data from some of the object fields. The href for the links is generated using a get_absolute_url method that I've written in the model itself. The problem is that the database is queried each time get_absolute_url is run. This causes many duplicate queries (in the future, with more objects, this will be a problem). Attempted Solutions My get_absolute_url method accesses some ForeignKey fields from my model, so I tried to use .select_related() for my queryset in my view. This did not change anything though. Question How can I eliminate the duplicate queries from running get_absolute_url? Code models.py class LanguageLocale(models.Model): """model for representing language locale combinations""" class LANG_CODES(models.TextChoices): EN = 'en', _('English') ES = 'es', _('español') QC = 'qc', _("K'iche'") lang = models.CharField(max_length=2, choices=LANG_CODES.choices, blank=False) class Scenario(models.Model): """model for representing interpreting practice scenarios""" scenario_id = models.CharField(max_length=20, primary_key=True) lang_power = models.ForeignKey(LanguageLocale) lang_primary_non_power = models.ForeignKey(LanguageLocale) class SCENARIO_STATUSES(models.TextChoices): PROD = 'PROD', _('Production') STGE = 'STGE', _('Staged') EXPR = 'EXPR', _('Experimental') status = models.CharField( max_length=4, choices=SCENARIO_STATUSES.choices, default='EXPR') def get_absolute_url(self): """Returns the URL to access a detail record for this scenario.""" return reverse('dialogue-detail', kwargs={ 'lang_power': self.lang_power.lang, 'lang_primary_non_power': self.lang_primary_non_power.lang, … -
How to keep main menu collapsed when accessing subpages on small devices in Django?
I have a website that I built in Django. I have a problem when the website is opened in a small device (smartphone). If I open the website in a small device the main menu on the main webpage collapses into a hamburger (this is desidered), but once I go to a subpage, the main menu expands completely looking awful. The main webpage and subpages have a base that is used in both. Below are the packages and versions I am currently using: Django==3.2.5 django-mathfilters==1.0.0 gunicorn==20.1.0 httplib2==0.14.0 numpy==1.21.2 oauthlib==3.1.0 Pillow==7.0.0 pipreqs==0.4.10 requests==2.22.0 simplejson==3.16.0 sqlparse==0.4.1 urllib3==1.25.8 whitenoise==5.3.0 dj-database-url==0.5.0 boto3==1.18.42 django-storages==1.11.1 psycopg2 django_heroku I expect the main menu on both types of pages: home or subpages, to be shown as a hamburger/collapsed option. -
Django optimize waiting for a response
I'm trying to speed up my Django server which is running let's say 4 processes and for some view, it is making a request to another server which is performing some computation and sending a request to another server. Which is taking a very long time to respond let's say 5 minutes, in that case, my server will get stuck after 4 requests in a short period of time. How can I optimize it, I believe it is due to busy waiting for the request, is it possible to respond to other requests and finish replying to that request after the response from another server. I believe the solution for that is async view in Django, but do I have to convert the whole view or can I convert just the function calling the external server? -
Django OperationError when trying to create an entry
I'm receiving the following OperationError when I try to add a new post using my superuser on the admin site. OperationalError at /admin/blog/post/add/ table blog_post has no column named author_id Request Method: POST Request URL: http://127.0.0.1:8000/admin/blog/post/add/ Django Version: 4.2.1 Exception Type: OperationalError Exception Value: table blog_post has no column named author_id I'm sure I'm doing something wrong in my models.py This is the class I created for this table class Post(models.Model): class Status(models.TextChoices): DRAFT = 'DF', 'Draft' PUBLISHED = 'PB', 'Published' title = models.CharField(max_length = 250) slug = models.SlugField(max_length=250) author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts') body = models.TextField() publish = models.DateTimeField(default=timezone.now) created = models.DateTimeField(auto_now_add = True) updated = models.DateTimeField(auto_now=True) status = models.CharField(max_length=2, choices=Status.choices, default=Status.DRAFT) class Meta: ordering = ['-publish'] indexes = [ models.Index(fields=['-publish']), ] def __str__(self) -> str: return self.title I just have set admin.py and settings.py to recognize the class, and database migrations are done but the error persists. -
python:can't install pillow in windows
i am trying to install Pillow on Windows but every time the error below faces me: *Note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for Pillow Running setup.py clean for Pillow Failed to build Pillow ERROR: Could not build wheels for Pillow, which is required to install pyproject.toml-based projects*` I Have tried to install different Python versions and update setup tools and the below commands: python -m pip install --upgrade Pillow how can I fix this error? -
How to Fix AJAX Filtered Product List that does not render images in Django Ecommerce Project?
I am trying to implement filter functionality in my Ecommerce Project. I ran into some problem when I generated filtered product list using AJAX, the products are all showing but images are not. After successfully sending and receiving data from the backend using AJAX, I thought it would work but it didn't. -
Create deb file for django
I have a Django app that I have to install it on customer server. I want to made a .deb package for this app, and add my custom repo, then on my customer server, get it like apt-get install {PACKAGE_NAME} . my questions: A- is there any better solution? B- how can I create a .deb package file for Django app? I Read about making packages but I am more confused -
Django Generic detail view 'class' must be called with either an object pk or a slug in the URLconf while trying to delete an object
In my Django app, I'm trying to delete a Comment which is associated with a post, but I keep getting this error message. The expected output is for the Comment to be deleted from the site and the database. Exception Type: AttributeError Exception Value: Generic detail view CommentDeleteView must be called with either an object pk or a slug in the URLconf. I am new to Django and I don't know how to resolve this error. urls.py: from django.urls import path from .views import CommentCreateView, CommentDeleteView from . import views urlpatterns = [ path('post/<int:pk>/comment', CommentCreateView.as_view(), name='add-comment'), path('post/<int:post_pk>/comment_delete/<int:comment_pk>/', CommentDeleteView.as_view(), name='comment-delete'), ] CommentDeleteView: class CommentDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView): model = Comment template_name = 'blog/comment_delete.html' context_object_name = 'comment' def test_func(self): comment = self.get_object() return comment.author == self.request.user def get_success_url(self): return reverse('post-detail', kwargs={'pk': self.object.post.pk}) def get_object(self, queryset=None): obj = super().get_object(queryset=queryset) return get_object_or_404(Comment, pk=obj.pk) Comment model: class Comment(models.Model): post = models.ForeignKey(Post, related_name="comments", on_delete=models.CASCADE) author = models.ForeignKey(User, on_delete=models.CASCADE) content = models.TextField() date_posted = models.DateTimeField(default = timezone.now) def __str__(self): return self.content Html template where the Delete Comment button is located: {% for comment in post.comments.all %} <article class="media content-section"> <div class="media-body"> <div class="article-metadata"> <small class="text-muted">Posted: {{ comment.date_posted|date:"H:i, j F, Y" }}</small> {% if comment.author == user or post.author … -
Fastest way to find out whether row or one of set of rows exists in database accesed via SqlAlchemy
Django has queryset.exists() method that fetch bool indicating whether or not at least 1 row with specific conditions exists. for example User.objects.filter(id__in=[1, 2, 3, 4, 5], usernmae='test').exists() It would just return bool True in case at least one row with these conditions exists and False other way around. Question - is it something like that could be done in SQLAlchemy > 2.0 with asyncpg driver? Best I have found is await session.get but it potentially could fetch multiple objectds from DB, dezerialize them, etc, whereas I only need to find out if at least one of these rows does exists? -
Is there a way to create multiple forms in Django using Bootstrap for updating values in a JSONField dictionary?
I want to create an update form in Django, which I suppose, it is not really complicated, but I need to know which way is a standard way to implement it. I try to simplify it. So let's imagine: models.py: class Building(models.Model): """ORM representation of the Projects""" name = models.CharField(max_length=64, blank=False, null=False) project = models.JSONField(default=building_default_value, blank=False, null=False) A simplified example of project: { "floor": { "Stahlbeton": 200, "Estrich": 50, "Sauberkeitsschicht": 50, "Abdichtung": 10, "Dampfsperre": 2, "Schaumglas": 120, "Extrudiertes Polystyrol (XPS)": 120, }, "roofbase": { "Stahlbeton": 200, "Abdichtung": 10, "Dampfsperre": 4, "Kies": 50, "Extrudiertes Polystyrol (XPS)": 180, }, "wall": { "WDVS Verklebung und Beschichtung": 15, "Steinwolle-Daemmstoff": 140, "KS-Mauerwerk": 175, "Gipsputz": 15, }, } Now I want to have an update form in my HTML page, that user is able to edit each number of this materials. For example it should be rendered something like this: Floor: Stahlbeton = (place to modify number) Estrich = (place to modify number) and so on for all other keys. I tried to use {% bootstrap_form form %}, but the problem is that with this command, there is going to be just 2 forms for name and project, and I could not break it down to … -
How can I zip multiple uploaded files in Django and save the zip file into the database?
import zipfile from django.shortcuts import render, HttpResponse from . models import File def index(request): if request.method == 'GET': return render(request, 'index.html') elif request.method == 'POST': uploadedFiles = request.FILES.getlist('files') with zipfile.ZipFile('new.zip', 'w') as zip_file: for uploadedFile in uploadedFiles: file_name = uploadedFile.name file_data = uploadedFile.read() zip_file.write(file_name, file_data) # File.objects.create(file = zip_file) # How can I save the zip file in database? return HttpResponse('Successfull.') When I upload files occurs an error: **FileNotFoundError: [WinError 2] The system cannot find the file specified: 'Cap.txt' ** How can I solve this? -
Django m2m relationship only saving sometimes through django admin
Have been banging my head against a wall on this one for a while. I have a model called Car, in this is has a models.ManyToManyField of colours. class Car(models.Model): brand = models.CharField(max_length=70, default='', unique=True) colours = models.ManyToManyField('Colours') ... def fetch_data(self): #some code which gets data from an api and adds it to some fields def save(self, *args, **kwargs): self.fetch_data() super(Car, self).save(*args, **kwargs) For a while this has been working seamlessly. A Car can be saved with numerous colours. Recently, if I select a colour in django admin when adding a Car, I click save, the Car will be created. However, clicking back into the car in django admin and you can see there are no Colours attached to it. And looking at the database, the m2m values have not been added. However, if I stay on that Car's edit screen for a while (5 mins) in django admin, re click on the colours, and press save, it will save the colours half of the time. Does anyone have any idea what could be the issue with this? I have tried adding save_related() and save_model() in CarAdmin(admin.ModelAdmin) but to no avail. Thanks! -
in Django using hx-get in a template, it is sending the original placeholder
When i load the template, it is loaded with hx-get=""{% url 'xx_view' CI='placeholder' %}" And from jquery i change the placeholder with this. "{% url 'xx_view' CI='" + selectedValuesString + "' %} i browser debugger i can see it is substituted correctly to this.Timestamp is for making sure it is not cached. /base/tools/?CI=hostxxxx&timestamp=1685534181063 But in the view the i receive CI=placeholder, and i cant get the timestamp using: timestamp = request.GET.get('timestamp'). so is hx-get cached somewhere else or what am i doing wrong? -
Why am I getting 'AttributeError: 'Response' object has no attribute 'get'' when trying to redirect in Django?
I'm creating web shop with django and i have this isue every time i try to redirect from my app which register and login users I wrote this code: def user_register(request): if request.method == 'POST': form = UserRegistrationForm(request.POST) if form.is_valid(): data = form.cleaned_data user = User.objects.create_user( data['email'], data['full_name'], data['password'] ) return redirect('https://www.google.com.ua/') else: form = UserRegistrationForm() context = {'title':'Signup', 'form':form} return render(request, 'register.html', context) No matter where i redirect it throws this error: File "C:\Users\rr006\AppData\Local\Programs\Python\Python310\lib\site-packages\django\middleware\clickjacking.py", line 26, in process_response if response.get('X-Frame-Options') is not None: AttributeError: 'Response' object has no attribute 'get' -
Django app [WARNING] Worker with pid 12276 was terminated due to signal 9
I have a Django application which runs on a linode server. I use a gunicorn for deployment. When I try to upload a large file of 40MB on the website (which is one of the functionalities). The website crashes: 502 Bad Gateway nginx/1.14.2. When I view the error logs, this is what I get: [WARNING] Worker with pid 12276 was terminated due to signal 9. I already tried adding these lines to the server block of the nginx configuration file: client_max_body_size 100M; client_body_timeout 1000s; client_header_timeout 1000s; and this to the gunicorn: ExecStart=/home/jelleheijne/.local/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/jelleheijne/NPS_data_processing.sock NPS_data_processing.wsgi:application --timeout 1000 to increase memory and time before timeout, but this does not work. Can anyone please help me solve this issue?