Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Unable to access Django server running in EC2 instance
I'm trying to run a Django(or really any server to begin) in an ec2 instance like in this tutorial: https://dev.to/awscommunity-asean/create-and-deploy-python-django-application-in-aws-ec2-instance-4hbm The issue is that I can't access the server from my browser despite setting my security group in a way that enables traffic from outside. In the ec2 instance (I am able to ssh in) I have a django server running with python3 manage.py runserver 0:8000 I also set ALLOWED_HOSTS = ['*'] in settings.py My inbound rules are as follows: I try to access the webpage with :8000 with no luck I would like to know where there are sources for error in this process and if there's anything I can do to test the server. If I missed anything let me know. -
Translations tabs of Django parler not showing in the view
I'm using django parler to translate my models. now i'm creating a custom admin Panel and i have a view for create and update of Contents. I'm using a class based view inherit from "View" for both create and update views so i can't use the TranslatableCreateView and TranslatableUpdateView. I saw in the codes of Django parler that using TranslatableModelFormMixin you can add translation support to the class-based views. I used this mixin but still i don't have access to the language tabs. Here is Views.py: class ContentCreateUpdateView(TranslatableModelFormMixin, TemplateResponseMixin, View): module = None model = None obj = None template_name = 'content-form.html' def get_model(self, model_name): if model_name in ['text', 'video', 'image', 'file']: return apps.get_model(app_label='courses', model_name=model_name) return None def get_form(self, model, *args, **kwargs): Form = modelform_factory(model, exclude=['owner', 'order', 'created', 'updated']) return Form(*args, **kwargs) def dispatch(self, request, module_id, model_name, id=None): self.module = get_object_or_404(Module, id=module_id, course__owner=request.user) self.model = self.get_model(model_name) if id: self.obj = get_object_or_404(self.model, id=id, owner=request.user) return super().dispatch(request, module_id, model_name, id) def get(self, request, module_id, model_name, id=None): form = self.get_form(self.model, instance=self.obj,) return self.render_to_response({'form': form, 'object': self.obj}) def post(self, request, module_id, model_name, id=None): form = self.get_form(self.model, instance=self.obj, data=request.POST, files=request.FILES) if form.is_valid(): obj = form.save(commit=False) obj.owner = request.user obj.save() if not id: # new content … -
Getting "IntegrityError" in Django models when trying to create
I am working on an app with Django backend and I am currently developing the signup page. Here's my code: models.py from django.db import models from django.contrib.auth.models import User from django.core.validators import MaxValueValidator, MinValueValidator from datetime import date from .countries import COUNTRIES from .hobbies import HOBBIES class Hobbies(models.Model): hobby = models.CharField(max_length=255, choices=HOBBIES) class Profile(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) def username(self): usern = User.objects.get(id=self.user.id) usern = usern.username return usern setup = models.BooleanField(default=False) gender = models.CharField(max_length=100, blank=True) dob = models.DateField(blank=True) def age(self): today = date.today() age = today.year - self.dob.year - ((today.month, today.day) < (self.dob.month, self.dob.day)) return age orgin = models.CharField(max_length=300, choices=COUNTRIES, blank=True) lives = models.CharField(max_length=300, choices=COUNTRIES, blank=True) bio = models.CharField(max_length=150, blank=True) email = models.CharField(max_length=255, blank=True) image = models.ImageField(upload_to='images', blank=True) hobbie = models.ManyToManyField('Hobbies', blank=True) views.py- from django.shortcuts import render from rest_framework import viewsets, status from .serializers import UserSerializer, ProfileSerializer from .models import Profile from django.db import IntegrityError from rest_framework.response import Response from rest_framework.decorators import action from django.contrib.auth.models import User from rest_framework.authentication import TokenAuthentication from rest_framework.permissions import IsAuthenticated, AllowAny from rest_framework.permissions import IsAuthenticatedOrReadOnly, BasePermission from django.http import JsonResponse from django.views.decorators.csrf import csrf_exempt import json from django.contrib.auth import authenticate # Create your views here. #..... @csrf_exempt def signup(request): if request.method == 'POST': data = … -
How to fix Django / python free(): invalid pointer?
When I run the django manage.py app, I got free(): invalid pointer error. Example: >python manage.py check System check identified no issues (0 silenced). free(): invalid pointer Abortado (imagem do núcleo gravada) The django app is running fine but I'm trying to get rid off this message. How can I fix this error or get more info to debug it? Python 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0] on linux (Ubuntu 20.04) Django==2.2.28 with virtualenv -
How to make a search filter on the django website
I have a database with the name of the attached files models.py class UploadFile(models.Model): user = models.ForeignKey(User,on_delete = models.CASCADE,related_name='file_created' ,verbose_name='Автор') title = models.CharField(max_length=200, verbose_name='Заголовок') # uploadedfile = models.FileField(upload_to='files/',null=True, verbose_name='Файл') description = models.TextField(blank=True, verbose_name='Описание') createdtime = models.DateField(auto_now_add=True, db_index=True, verbose_name='Дата создания') price = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True, verbose_name='Цена') number_course = models.IntegerField(null=True, blank=True, verbose_name='Курс') number_semestr = models.IntegerField(null=True, blank=True, verbose_name='Семестр') subjectt = models.CharField(max_length=200, null=True,verbose_name='Предмет') type_materials = models.CharField(max_length=200,null=True, verbose_name='Тип работы') institute = models.CharField(max_length=200, null=True, verbose_name='Институт') def __str__(self): return self.title class Meta: verbose_name = 'Загрузка файла' verbose_name_plural = 'Загрузка файлов' I need to make a filter on the table that is obtained when uploading a file: Page with table: <div style="float: right; margin-bottom: 10%; margin-top: 10%;" class="form-group row" data-aos="fade-up"> <form action="" method="post" style="width:90%"> {% csrf_token %} <!-- {{form|crispy}}--> <p><label class="form-label" for="{{ form.number_course.id_for_label }}">Курс: </label> {{ form.number_course }}</p> <div class="form-error">{{ form.number_course.errors }}</div> <p><label class="form-label" for="{{ form.number_semestr.id_for_label }}">Семестр: </label> {{ form.number_semestr }}</p> <div class="form-error">{{ form.number_semestr.errors }}</div> <p><label class="form-label" for="{{ form.subjectt.id_for_label }}">Дисциплина </label> {{ form.subjectt }}</p> <div class="form-error">{{ form.subjectt.errors }}</div> <p><select name = "type_materials" required class="form-select" aria-label="Тип материала"> <option selected>Тип материала</option> <option value="Практические работы">Практические работы</option> <option value="Лабораторные работы">Лабораторные работы</option> <option value="Курсовые">Курсовые</option> <option value="Дипломная работа">Дипломная работа</option> <option value="Лекции">Лекции</option> <option value="Диск с работами">Диск с работами</option> <option value="Другое">Другое</option> </select></p> <p><select name = … -
Django basic ModelForm get success url not working
I created first app with Django. I added first ModelForm, but it is not working when clicking on Submit. # Create your models here. from django.db import models import datetime from django.utils import timezone from django.urls import reverse class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) def __str__(self): return self.question_text def get_success_url(self): return reverse('polls:detail', args=(self.get_object().id,)) class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) def __str__(self): return self.choice_text And forms from django.forms import ModelForm from .models import Question, Choice class QuestionForm(ModelForm): class Meta: model = Question fields = '__all__' def get_success_url(self): # 4 is is random hardcoded number for testing return reverse('polls:detail', args=(4)) When clicking on Send Message after filling form in valid way, I get this exception Even when added get_success_url to model and to form. Anybody ani tips? -
Django instert key-value into a specific place in JSON
I have 3 endpoints that return the same JSON response but with different values. For one of those endpoints, I need to return only one more key-value pair but in a specific place of the JSON, so I can't just add it at the end. Here is an example of what I need to do: response = { 'oid': oid, 'n': n, 'oidp': oidp, 'np': np, 'o': o, 'contains_source': contains_source, 'treg': end_time - start_time, } response = { 'oid': oid, 'n': n, 'oidp': oidp, 'np': np, **'box': boxid,** 'o': o, 'contains_source': contains_source, 'treg': end_time - start_time, } I need to add box:boxid right after np:np. Is there any way I can do that? Or it's just possible to add a value at the end? Thanks in advance! -
How to create a relationship on the field of a model with three different models in django?
Just a fool question I have a model Exam which contains a field Subject which I want to connect with 3 or 4 or even 5 subjects like foreign key connect one with it. # 1 type class Math(models.Model): id = models.CharField(primary_key=True, max_length=200, blank=True) chapter = models.ForeignKey(Chapters, on_delete=models.CASCADE) name = models.CharField(max_length=250) marks_contain = models.IntegerField(default=10) question = RichTextUploadingField() hint = RichTextUploadingField() created_at = models.DateTimeField(auto_now_add=True, blank=True) # 2 type class Science(models.Model): id = models.CharField(primary_key=True, max_length=200, blank=True) chapter = models.ForeignKey(Chapters, on_delete=models.CASCADE) name = models.CharField(max_length=250) marks_contain = models.IntegerField(default=10) question = RichTextUploadingField() hint = RichTextUploadingField() created_at = models.DateTimeField(auto_now_add=True, blank=True) # 3 type class Computer(models.Model): id = models.CharField(primary_key=True, max_length=200, blank=True) chapter = models.ForeignKey(Chapters, on_delete=models.CASCADE) name = models.CharField(max_length=250) marks_contain = models.IntegerField(default=10) question = RichTextUploadingField() hint = RichTextUploadingField() created_at = models.DateTimeField(auto_now_add=True, blank=True) class Exam(models.Model): id = models.AutoField(primary_key=True) created_at = models.DateTimeField(auto_now_add=True, blank=True) name = models.CharField(max_length=255) subject = models.ForeignKey([Math, Science, Computer]) # I want to do something like this I know this is not possible with foreign-key but what is the way to do things like this? -
Wiki Search Project - Creating a New Page - My home screen link works fine, but my new page will not save to the directory
New Page: Clicking “Create New Page” in the sidebar should take the user to a page where they can create a new encyclopedia entry. 1.Users should be able to enter a title for the page and, in a textarea, should be able to enter the Markdown content for the page. Users should be able to click a button to save their new page. 2.When the page is saved, if an encyclopedia entry already exists with the provided title, the user should be presented with an error message. 3.Otherwise, the encyclopedia entry should be saved to disk, and the user should be taken to the new entry’s page. So I'm working on this Django project and I am realizing that Django is not my favorite. I currently have my Wiki Site functioning the way I want it to but I am stuck on how to "Create a New Page". My link on my home screen works fine >>> Takes me to a New Page that I can create. The problem is that when I try to Save the Page my page gets redirected back to the original page with no content. How do I change my code so that it Saves … -
Django Rest Framework with Mozilla Django OCID
I've been working on this Drf app to sign certificates. I have been using simple JWT for token authentication. But now I need to implement SSO authentication, so I have been trying to use Mozilla - Django - OIDC, but I can't seem to figure out the docs. I'm confused on where the access and refresh tokens would come from, since it clearly says in the docs. Note that this only takes care of authenticating against an access token, and provides no options to create or renew tokens. If mozilla-django-oidc is not creating the tokens, then where do I obtain them from and where will they be stored when I try to access them in my React frontend. Thank you in advance for any help!! -
Django perform a join on multiple tables
I have the following tables, class A: field_1 = models.CharField() field_2 = models.IntegerField() class B: a = models.ForeignKey(A, related_name='table_b') some_other_field = models.CharField() class C: b = models.ForeignKey(B, related_name="table_c") other_field = models.CharField() Let's assume ids are provided for objects on table A, I need to get all the C objects that are related to table A through table B. I have the following query, which gives me what I need but I am wondering if there is a better way to do this, I was reading into prefetch_related and select_related but can't wrap my head around on how to use them so far c_list = C.objects.filter(b__in=B.objects.filter(a__pk__in=table_a_ids)) Also, I would like to group them by other_field Any help is much appreciated. -
Trying to convert a function based view to a generic detail view
Creating a comment system for a ticket django project. I've completed most of the functionality for the comment, except I'm not quite sure how to implement the POST method so that I can use the frontend to create comments. If I use the admin site, it works and shows up in the view, but I get an error when I try to submit using the frontend form. I'm not sure how to proceed, any help is much appreciated. Here's the original function based view def ticket_single(request, post): ticket = get_object_or_404(Ticket, slug=ticket, status='published') allcomments = ticket.comments.filter(status=True) user_comment = None if request.method == 'POST': comment_form = NewCommentForm(request.POST) if comment_form.is_valid(): user_comment = comment_form.save(commit=False) user_comment.ticket = ticket user_comment.save() return HttpResponseRedirect('/' + ticket.slug) else: comment_form = NewCommentForm() return render(request, 'ticket_detail.html', {'ticket': ticket, 'comments': user_comment, 'comments': comments, 'comment_form': comment_form, 'allcomments': allcomments, }) Here's what I have so far in the DetailView class TicketDetailView(DetailView): model = Ticket def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['comments'] = Comment.objects.filter(ticket=self.object) context['comment_form'] = NewCommentForm() return context def post(self, request, *args, **kwargs): if request.method == 'POST': comment_form = NewCommentForm(request.POST) if comment_form.is_valid(): user_comment = comment_form.save(commit=False) user_comment.save() return render(request, 'ticket_detail.html', {'comments': user_comment, 'comment_form': comment_form}) -
How implement django.views.generic for logoutPage/loginPage if earlier used request?
This my view.py What bast practice for migration from request to django.views.generic? How implement django.views.generic for logoutPage/loginPage if earlier used request? from django.shortcuts import render,redirect from django.http import HttpResponse from .models import * from django.contrib.auth import login,logout,authenticate from .forms import * from django.views.generic import ListView def logoutPage(request): logout(request) return redirect('/') def loginPage(request): if request.user.is_authenticated: return redirect('home') else: if request.method=="POST": username=request.POST.get('username') password=request.POST.get('password') user=authenticate(request,username=username,password=password) if user is not None: print("working") login(request,user) return redirect('/') context={} return render(request,'book/templates/login.html',context) -
How to parse generic text query into dictionary - Python
I'm trying to parse generic text query that can look as the following in Python: first_name:Jon last_name:"Doe" address:"1st X street, Y, California" to: { "first_name":"Jon", "last_name":"Doe", "address":"1st X street, Y, California" } Any ideas how to do it while being able to properly parse text between quotes and spaces? -
Djoser unused endpoints
I don't need all endpoints that Djoser have. How i can switch off them? In documentation: SetPasswordView, PasswordResetConfirmView, SetUsernameView, ActivationView, and ResendActivationView have all been removed and replaced by appropriate sub-views within UserViewSet. But i don't find how to work with UserViewSet. I need: GET-api/users/ POST-api/users/ GET-api/users/{id}/ GET-api/users/me/ POST-api/users/set_password/ How can i set this endpoints, and hide or better delete others? -
Django Rest Framework application with gunicorn deployment
I have a django rest framework application that's using class style views. The API written on it takes (let's say) 5s to response. My deployment is simple: gunicorn --workers=4 application_name.wsgi -b 0.0.0.0:8000 But what this does is it takes only 4 requests at a time. If I bombard 20 requests concurrently. It processes the first 4, then next 4, & so on... What do I have to do so that it returns response for all 20 requests in 5s(if all takes, 5s let's say). I'm stuck here for a week now. -
How to adapt my CKEDITOR size in css and django?
I try to adapt the CKEDITOR in the textarea assign to but it overide textarea ? How to change so it match the textarea as below ? I uncheck the element.style { /* width: 835px; */ } and there it fits in textarea , what should I do ? enter image description here -
PostgreSQL database not showing data on Django website
I've converted my SQLite DB to a PostgreSQL DB. I've made all the migrations and collectstatic, and in my python script on my windows PC, I can access the DB and execute commands. My problem is that I don't see all that data on my website...It's like the server and Python talk to each other but not to the website. Here are a couple of code snippets- PC Python Script def get_query(group_name , heb_sale_rent ,heb_street, heb_city , heb_rooms , heb_size , heb_floor , heb_porch , heb_storage , heb_mamad , heb_parking , heb_elevator , heb_phone , heb_price): conn = psycopg2.connect(database='test', host='192.168.72.130', port='5432', user='user_sql', password='user_sql') cur = conn.cursor() cur.execute("SELECT * FROM to_excel") query = cur.fetchall() if I run this command I can see results I have added to the DB- (so far so good) On My Ubuntu Server #in settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'test', 'USER': 'user_sql', 'PASSWORD': 'user_sql', 'HOST': 'localhost', 'PORT': '5432', } } But on the website- nada- Where is all the data that Python printed out in the query? What am I doing wrong? help, please! P.S- I don't know if it has any relevance, but when I run sudo -u postgres psql and then … -
Build a data heavy project with drf
I'm going to work on a project(Django and DRF) which is going to have lots of data and from that I've to calculate meaningful data (percentage, variance, average, etc). It's also going to have lots of graphs and different sorts of charts. Is there any Github repo or any platform where I can get help or take a reference from? -
Django - ordering after distinct raises error - how to make it work?
I have a custom QuerySet method that filters users with at least one mortgage. To not get duplicates, I have to add .distinct('pk'). The problem is that API allows on-demand ordering. That means, I can't just order the queryset before calling distinct. How can I make it work? The custom queryset: class UserQuerySet(models.QuerySet): def is_applicant(self): return self.filter(mortgages__isnull=False).distinct('pk') This is the relation: applicant = models.ForeignKey('User', verbose_name='Žiadateľ', on_delete=models.PROTECT, related_name='mortgages') Can I make the is_applicant method work without using distinct? Right now, if I try to order it, it raises: ProgrammingError SELECT DISTINCT ON expressions must match initial ORDER BY expressions LINE 1: SELECT COUNT(*) FROM (SELECT DISTINCT ON ("users_user"."id")... -
Translating {{ model.name }} data dynamically in django template
Can anyone suggest shortest way to translate {{ model.name }} type of data in django template? -
How to add dynamic field to django.core.serializers.serialize
I'm trying to export a queryset into json format. However, my query has a dynamic field (ie not defined in the model), and when I try to add it nothing shows. My model: class MyModel(models.Model): id = models.TextField(primary_key=True, blank=True) quantity = models.IntegerField(null=True, blank=True) rate = models.IntegerField(null=True, blank=True) class Meta: managed = False My queryset: qs = MyModel.objects.filter(id=id).annotate(result=F('rate') * F('quantity')) My call: class ClassName: @classmethod def build__json(cls, queryset): geojson_str = serialize('json', queryset, fields=('result') ) my_geojson = json.loads(geojson_str) return my_geojson qs_json = ClassName.build_json(qs) Is there a way to use serialize to do this? Or do I need to write a custom class? PS: I'm not building a view, just trying to convert a queryset into a json. Thanks in advance -
How to access the Data of an model using particular id in django rest framework
I want to access the data of an model which is named as IssueReport by using it's ID in django rest framework so I used the post method for passing the ID manually to get the IssueReport data by that ID but it gives me the Error as, Method Not Allowed: /app/auth/getissuereport/ [10/Aug/2022 23:26:21] "GET /app/auth/getissuereport/ HTTP/1.1" 405 7036 Internal Server Error: /app/auth/getissuereport/ Traceback (most recent call last): File "D:\MMRDA\.venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) File "D:\MMRDA\.venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "D:\MMRDA\.venv\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "D:\MMRDA\.venv\lib\site-packages\django\views\generic\base.py", line 84, in view return self.dispatch(request, *args, **kwargs) File "D:\MMRDA\.venv\lib\site-packages\rest_framework\views.py", line 509, in dispatch response = self.handle_exception(exc) File "D:\MMRDA\.venv\lib\site-packages\rest_framework\views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "D:\MMRDA\.venv\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception raise exc File "D:\MMRDA\.venv\lib\site-packages\rest_framework\views.py", line 506, in dispatch response = handler(request, *args, **kwargs) File "D:\MMRDA\mmrda\apis\views.py", line 195, in post report=IssueReport.objects.get(pk=id) File "D:\MMRDA\.venv\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "D:\MMRDA\.venv\lib\site-packages\django\db\models\query.py", line 496, in get raise self.model.DoesNotExist( DataSet.models.IssueReport.DoesNotExist: IssueReport matching query does not exist. This is my views.py, class GetIssueReportById(generics.GenericAPIView): serializer_class=GetIssueReportSerializer def post(self,request,*args,**kwargs): serializer=self.get_serializer(data=request.data) if serializer.is_valid(raise_exception=True): id=serializer.data.get('id') report=IssueReport.objects.get(pk=id) data=IssueReportSerializer(report,context=self.get_serializer_context()).data return Response({ 'message':"Data Fetched successfully", 'status':"success", 'data':data, },status=status.HTTP_200_OK) else: return Response({ … -
Passing Javascript value into CSS?
I'm trying to pass my javascript value (a percentage) into the css 100% width line which is currently at 30%. This currently creates a table that populates outward, starting at 0 and then going out to 30%, I want to be able to implement my Javascript value (c2_percent) instead of the 30% value. If anyone can help that would be great. Thanks <div class="bar-graph bar-graph-horizontal bar-graph-one"> <div class="bar-one"> <span class="rating-a1">A1</span> <div class="bar" id="rating-a1" data-percentage=""></div> </div> <div class="bar-two"> <span class="rating-a2">A2</span> <div class="bar" data-percentage="11%"></div> </div> <div class="bar-three"> <span class="rating-a3">A3</span> <div class="bar" data-percentage="7%"></div> </div> <div class="bar-four"> <span class="rating-b1">B1</span> <div class="bar" data-percentage="10%"></div> </div> <div class="bar-five"> <span class="rating-b2">B2</span> <div class="bar" data-percentage="20%"></div> </div> <div class="bar-six"> <span class="rating-b3">B3</span> <div class="bar" data-percentage="5%"></div> </div> <div class="bar-seven"> <span class="rating-c1">C1</span> <div class="bar" data-percentage="9%"></div> </div> <div class="bar-eight"> <span class="rating-c2">C2</span> <div class="bar" id="c2-rating" data-percentage=""></div> </div> <div class="bar-nine"> <span class="rating-c3">C3</span> <div class="bar" data-percentage="5%"></div> </div> <div class="bar-ten"> <span class="rating-d1">D1</span> <div class="bar" data-percentage="5%"></div> </div> </div> @-webkit-keyframes show-bar-eight { 0% { width: 0; } 100% { width: 30%; } } <script> for(let i = 0; i < 1; i++) { const c2_security_values = Array.from(document.querySelectorAll('.security-value-c2')); const c2_security_values_inner = c2_security_values.map((element) => element.innerText); const c2_summed_values = c2_security_values_inner.reduce((accumulator, currentValue) => parseInt(accumulator) + parseInt(currentValue)); const total_security_values = Array.from(document.querySelectorAll('.individual-market-value')); const total_security_values_inner = total_security_values.map((element) … -
CORS error during API call for React/DRF app on Heroku
I have my react front end and my django rest api as two separate apps on heroku. I'm having the issue of the following error: The request options I use for the fetch request on the frontend: const credentials = btoa(`${data.get('username')}:${data.get('password')}`); const requestOptionsSignIn = { method: "POST", credentials: 'include', headers: { 'Accept': 'application/json, text/plain', 'Content-Type': 'application/json', "Authorization": `Basic ${credentials}` }, body: JSON.stringify({}) } And my Django/django-cors-headers settings: CORS_ORIGIN_ALLOW_ALL = False CORS_ALLOW_CREDENTIALS = True CORS_ALLOWED_ORIGINS = ['https://_____frontend.herokuapp.com'] CORS_ALLOW_HEADERS = ("x-requested-with", "content-type", "accept", "origin", "authorization", "x-csrftoken") I've tried playing around with the settings but I can't get it to work.