Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django full text search: how to match multiple words in the query
I'm using SearchVector to search all the occurences of a query string contained at least in one of the fields of MyModel. I'm doing this way using icontains: # search_fields is the list of MyModel fields MyModel.objects.annotate( search=SearchVector(*search_fields), ).filter(search__icontains=query) and if I have: m1 = MyModel(foo='foobar', bar = 'bar', baz = 'baz') m2 = MyModel(foo='fooooo', bar = 'barooo', baz = 'bazooo') m3 = MyModel(foo='fooxxx', bar = 'barxxx', baz = 'bazxxx') This works fine if my query is a single word. E.g., foo returns m1, m2, m3 aro returns m2 But I have problems if the query contains more than one word. Indeed: foo bar returns nothing instead of m1, m2, m3 aro azo returns nothing instead of m2 Is there a way to use Django Full Text Search to achieve what I need? -
Django App not connecting to RDS since SSL/TLS Cert Updates
I have a Django app running on ELB connecting to a MySQL RDS db. I checked recently and its no longer working (application is up fine but I get the following error when I try and deploy or run any manage.py db related commands. I can connect to the RDS DB manually without a problem. django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '****.eu-west-1.rds.amazonaws.com' (110)"). I believe this is to do with the recent updates to SSL/TLS certificates - however I've gone into my RDS dashboard and updated to the new 2019 version there and I'm still getting this error. Does anyone know what might be causing this? It worked fine before the cert change so I can only assume it's related. I've tried adding the ssl-ca rds-ca-2019-root.pem to the DB options in django but still get the same error regardless. Any help would be super appreciated as I'm pretty stumped currently. Thanks! -
Class.objects in django
So here is my code def index(request): latest_question_list = Question.objects.order_by('-pub_date')[:5] context = {'latest_question_list': latest_question_list} return render(request, 'polls/index.html', context) This is my model for my Django project class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question_text def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) and here is the error Class 'Question' has no 'objects' member -
How to get data from Ajax request and change the HTML according to this?
I have tried to make an ajax request for getting the background task status but I cannot get the data. Here is my Ajax request; var ii=setInterval(function() { $.ajax({ type: "get", url: '{% url "data:status" %}', success:function (data) { console.log(data) } }); }, 5000); function Cii(){ clearInterval(ii) } Here is my HTML; <div class="jumbotron text-center" id="status"> <div id="display_status"> {% if pending and running %} <p>{{pending}} Waiting.</p> <p>{{running}} Going on.</p> {% else %} {% if completed >= 0 %} <a href='#'> It's done, press for make prediction!</a> {% else %} <p>0 Waiting.</p> <p>0 Going on.</p> {% endif %} {% endif %} </div> </div> Here is the function which is triggered from ajax request; def get_process_status(): now = timezone.now() pending_tasks = Task.objects.filter(run_at__gt=now) running_tasks = Task.objects.filter(locked_at__gte=now) completed_tasks = CompletedTask.objects.all() connection.close() return len(pending_tasks), len(running_tasks), len(completed_tasks) And here is my view; @login_required(login_url = "user:login") def process_status_view(request): if request.is_ajax(): pending, running, completed = get_process_status() context = { "pending": pending, "running": running, "completed": completed, } return render(request, "pending_page.html", context) return render(request, "pending_page.html") How can I fix this? -
Reduce number of queries generated by Django ORM
I have below models class Order(models.Model): .... class Component(models.Model): line = models.ForeignKey( Line, on_delete=models.CASCADE, blank=True, null=True, related_name="components", ) ... class Detail(models.Model): line = models.ForeignKey( "Line", on_delete=models.CASCADE, blank=True, null=True, related_name="details", ) order= models.ForeignKey(Order, on_delete=models.CASCADE, related_name="details") ..... class Line(models.Model): .... **Serializer** class ComponentSerializer(serializers.ModelSerializer): qty = serializers.SerializerMethodField(read_only=True) def get_qty(self,component): return (component.qty)-sum( map( some_calculation, Detail.objects.filter( line__components=component,order__active=True) ) ) I have a list view using model viewsets def list(self, request): queryset = Order.objects.filter(order__user=request.user.id,active=True) serilizer = OrderSerializer(queryset,many=true) The component serializer is used inside the order serializer. My question is the query inside the ComponentSerializer hits every order record. If my understanding is correct is there any way to reduce this -
How to create model object via model mommy for inherited model in django?
I have a model which is inherited from Django User model. class CustomUser(User): ... How to create the model object using model mommy library? -
Custom AuthenticationForm never called
I am using custom authentication form to validate user name in Django. I following the process mentioned in link CustomAuthenticationForm. But class CustomAuthenticationForm or confirm_login_allowed never called after I press login button. Could you please let me know if I am missing anything. I am using Django 1.6.10. -
Javascript not executing with Django when file called from js block
I am trying to execute a simple javascript command on a project with Django and manage to do so from inside the HTML template but not when I import the javascript via a js block. What could be the reason ? In more detail, the JS is this : console.log("test"); document.querySelector('#js-table').style.height = "50px"; It works if i include it at the bottom of the HTML, wrapped between two <script> tags. But if i add at the bottom of the html template: {% block js %} <script src="{% static 'app/js/basic.js' %}"></script> {% endblock %} and run the same JS command, the console prints test and returns document.querySelector(...) is null -
django wsgi setup with settings subfolder
I'm trying differents environment settings for my project, below is my project folder structure: |-app |-project |-settings |-base.py |-dev.py |-prod.py |-urls.py |-wsgy.py In base.py, how can i setup WSGI_APPLICATION django settings variable to point wsgi file on parent folder ? base.py: WSGI_APPLICATION = 'project.wsgi.application' The error is: django.core.exceptions.ImproperlyConfigured: WSGI application 'project.wsgi.application' could not be loaded; Error importing module. Thanks in advance. -
what does "about:blank#blocked" error mean when using Django?
So I'm a beginner in Django. And whenever I try to access a page via tag in my template, I get the error. so below is my views.py def ArticleDetail(request, authuser_id, slug): thisArticle = myArticle.objects.get(slug=slug) return render(request, 'article/detail.html', {'thisArticle' : thisArticle}) urls.py urlpatterns = [ # some other urls path('article/<int:authuser_id>/<slug:slug>', views.ArticleDetail, name='ArticleDetail') ] And my html file that has all the articles listed {% extends 'main/base.html' %} {% block title %} DANSANG {% endblock %} {% block content %} {% for item in allArticles %} <!--allArticle is the instance that brings all objects(articles)--> <h1><a href="{{item.url}}">{{item.title}}</a></h1> <h2>{{item.url}}</h2> <h4>{{item.created}}</h4> <h4>{{item.modified}}</h4> <p>{{item.contents}}</p> {% endfor %} {% endblock %} I'm not sure if this is enough information you need. I've never seen the "about:blank#blocked" error, so I'd like to know what this error means. I appreciate your help :) -
django how to join two models with same fields
class plan(models.Model): baseyear = models.DateField() baseline = models.TextField() targetyear = models.DateField() target = models.TextField() frequency = models.ForeignKey(Frequency, on_delete=models.CASCADE) duration = models.ForeignKey(PlanDuration, on_delete=models.CASCADE) sectorresponsible = models.ForeignKey(Sector, on_delete=models.CASCADE) kpi = models.ForeignKey(Kpi, on_delete=models.CASCADE) class Performance(models.Model): plan = models.ForeignKey(Plan1, on_delete=models.CASCADE, blank=True, null=True) performance = models.TextField() report = models.FileField(upload_to='file/',null= True,default='not provided') year_of_performance = models.TextField(blank=True, null=True) kpi = models.ForeignKey(Kpi, on_delete=models.CASCADE,blank=True, null=True) how to join these models through target year and year_of _performance with similar values -
How to update a post using form wizard in Django
I have created a multipage form using the form wizard from the form tools package and it works. I am trying to create and update view so that I can be able to update the created post. I have tried using generic update view, this only display the page without the form. Then, I tried using the same code for the create view by using a get method but this seems not to work also. I will appreciate it if someone can point me in the right direction. Thanks. views.url class FormWizardView(SessionWizardView): template_name = "new_rental.html" form_list = [NewRentalPropertyForm, NewContractForm] file_storage = FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'images')) def done(self, form_list, **kwargs): rentalproperty_instance = RentalProperty() contract_instance = Contract() for form in form_list: rentalproperty_instance = construct_instance(form, rentalproperty_instance) contract_instance = construct_instance(form, contract_instance) rentalproperty_instance.save() contract_instance.rentalproperty = rentalproperty_instance contract_instance.save() return redirect('mini_rental:property_list') class UpdateWizardView(SessionWizardView): template_name = "update.html" form_list = [NewRentalPropertyForm, NewContractForm] file_storage = FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'images')) def done(self,pk, form_list, **kwargs): rentalproperty_instance = RentalProperty.objects.get(pk=pk) contract_instance = Contract() for form in form_list: rentalproperty_instance = construct_instance(form, rentalproperty_instance) contract_instance = construct_instance(form, contract_instance) rentalproperty_instance.save() contract_instance.rentalproperty = rentalproperty_instance contract_instance.save() return redirect('mini_rental:property_list') form. html Update rental listing {% load i18n %} <p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> <form method="post"> {% csrf_token %} <table> {{ wizard.management_form }} … -
How can set time range field in dajngo model
In Django model field has TimeField for store time but how can I store Time Range like start_time & end_time ? Is there any model field in django to do this job ? for example working_in_time = models.TimeRange(start_time, end_time) -
Migration dependencies reference nonexistent parent node when trying to migrate after db change
Before, I used to keep the same db for development and production (postgresql). This isn't the greatest idea, so I made it so that the db I was currently using would only be used in production (and I'd have an sqlite db locally). Well, I tried to migrate the production db and hot this traceback when trying to migrate at heroku: (bosnetvenv) michael@michael-VivoBook-ASUSLaptop-MJ401TA:~/projects/znet/bosnet$ heroku run python manage.py migrate › Warning: heroku update available from 7.35.0 to 7.38.1. Running python manage.py migrate on ⬢ zealchain... up, run.1153 (Hobby) /app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>. """) Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 79, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/loader.py", line 267, in build_graph raise exc File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/loader.py", line 241, in … -
how to fetch file of any format from postgre sql and show in template using django
enter image description here class manuals(models.Model): topic = models.CharField(max_length=100) semester = models.CharField(max_length=100) course = models.CharField(max_length=100) format = models.CharField(max_length=100) word = models.FileField(max_length=700,upload_to='media') Please guide me that how i can fetch my word file from this table and show in my template -
Django : Why doesn't django translate the words
This is my models. I have used gettext_lazy because it is models.py file from django.utils.translation import gettext_lazy as _ class User(AbstractUser): email = models.EmailField(_('email address'),unique=True) USERNAME_FIELD = "email" REQUIRED_FIELDS = ("username","first_name","last_name") This is my setting.py file.I have added only LANGUAGE_CODE = 'fr' LANGUAGES = ( ('en', _('English')), ('fr', _('French')), ) # Translation local path LOCALE_PATHS = ( os.path.join(os.path.dirname(BASE_DIR), 'locale'), ) This is done after the following process python manage.py makemessages -l 'fr' Then a mo file is created and I add my translation there but got no translation.Then after writing the code below a po file is created and contains all the translation in pdf file python manage.py compilemessages -
ImportError: cannot import name 'admin' from 'django.contrib
What is the problem that i can't solve?I have everything done in settings.py, i checked if admin is installed.This problem has only appeared today,i didn't have this problem before.Can somebody help please? Traceback (most recent call last): File "C:\Software Files\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Software Files\Python\Python38-32\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Software Files\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception raise _exception[0](_exception[1]).with_traceback(_exception[2]) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\apps\config.py", line 136, in create import_module(entry) File "C:\Software Files\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'django.contrib.admin' Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Software Files\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "C:\Software Files\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line … -
request.data not always a queryDict
Using a PATCH request on a RetrieveUpdateDestroyAPIView I receive the following in RetrieveUpdateDestroyAPIView.update when i run print(request.data): {'myVar': ''} when running automated tests using django rest framework's APIClient I get this: <QueryDict: {'myVar': ['']}> Why is this different? What can i do to ensure consistency between my environments of test and dev? -
Django Many=True doesn't work with to_representation
I have following situation. I need a PATCH for my device model to change the supplier. When a user set's parameter device on "ALL", all the devices need to be changed. Everything works but my serialiser doesn't return my supplier as validated data when the user wants ALL the devices to be changed because it's a many=true field. This is my patch: def patch(self, request, site_pk): """ PATCH the device's supplier info of the site. """ all_device_token = False if request.data.get("device") == "ALL": all_device_token = True arguments = {} else: device_pk = request.data.get("device") arguments = {"id": device_pk} devices = Device.objects.filter(site_id=site_pk, **arguments).all() if not devices.exists(): raise PermissionDenied("The device does not belong to the site.") if all_device_token: serializer_class = self.get_serializer_class() serializer = serializer_class( devices, many=True, data=request.data, partial=True, ) serializer.is_valid(raise_exception=True) new_supplier = get_object_or_404(Supplier, pk=request.data.get("supplier")) for device in devices: device.supplier_id = new_supplier.pk device.save() else: device = devices.first() serializer_class = self.get_serializer_class() serializer = serializer_class(device, data=request.data, partial=True,) serializer.is_valid(raise_exception=True) if "supplier" in self.request.data: new_supplier = serializer.validated_data["supplier"] device.supplier_id = new_supplier.pk device.save() return Response(serializer.data, status=status.HTTP_200_OK) Serializer: class AdminDeviceInfoSerializer(AdminDeviceSerializer): site = serializers.SerializerMethodField() owner = serializers.SerializerMethodField() country = serializers.SerializerMethodField() class Meta(AdminDeviceSerializer.Meta): fields = AdminDeviceSerializer.Meta.fields + [ "site", "owner", "country", "disk_space", "supplier", ] def to_representation(self, device): data = super().to_representation(device) if not device.supplier: … -
How to Store a Specific blank fields of user who is already Exist in the models
Views.py This my code as you can see in views.py file i am deriving the fields using request object I could have used form.save() but i am getting an error. I want to store this field data to that user model User is already Exist i had Used UserCreationForm from django.shortcuts import render from django.views.generic import TemplateView,CreateView from auctions.models import User from auctions import forms from django.urls import reverse from django.http import HttpResponseRedirect from django.urls import reverse_lazy from django.contrib.auth import settings from django.contrib import messages # Create your views here. # class HomePage(TemplateView): template_name = 'index.html' form_class = forms.ProfileSetupForm # success_url = reverse_lazy('auctions:profile_update') # template_name = 'index.html' users =User.objects.all() def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['users'] = self.users context['form']=forms.ProfileSetupForm() return context def post(self, request, *args, **kwargs): form = self.form_class(request.POST) if form.is_valid(): address= request.POST['address'] mobile = request.POST['mobile'] city =request.POST['city'] state = request.POST['state'] birth_date =request.POST['birth_date'] image=request.FILES['image'] # file= request.FILES['image'] user_name=request.POST['user_name'] pincode = request.POST['pincode'] print("abc",pincode,user_name,image) return HttpResponseRedirect('') class ThanksPage(TemplateView): template_name = 'thanks.html' forms.py Here in forms.py file two fields first_name and last_name comes from auth.models.User i assume class ProfileSetupForm(forms.ModelForm): # def save(self, commit=True): # user= models.User() class Meta(): fields=('image','first_name','last_name','address','mobile','birth_date','city','state','pincode') model=models.User # widgets={ # # } models.py Here auth.models.User are inherited so few fields … -
How to change timezone celery in models.py of django
i create a periodic tasks to to something in models.py in django , but when i run it run on UTC timezone , how can i change timezone class TimeSend(models.Model): user = models.ForeignKey(UserMail,on_delete=models.CASCADE,null=True) hour = models.CharField(max_length=10,blank=True,null=True) minute = models.CharField(max_length=10,blank=True,null=True) status = models.BooleanField(default=True) def __str__(self): return self.user.user_mail def set_periodic_task(self,task_name): schedule = self.get_or_create_crontab() PeriodicTask.objects.create( crontab=schedule, name=f'{self.user.user_mail}-{self.user.id}', task=task_name, kwargs=json.dumps({ 'recepient': self.user.user_mail, }) ) def get_or_create_crontab(self): schedule, created = CrontabSchedule.objects.get_or_create( minute=self.minute, hour=self.hour, day_of_week='*', day_of_month='*', ) return schedule in settings.py , i already change the timezone TIME_ZONE = 'Asia/Bangkok' USE_I18N = True USE_L10N = True USE_TZ = True CELERY_TIMEZONE = 'Asia/Bangkok' CELERY_ENABLE_UTC = False -
JS TypeError when not waiting for the document to be ready [duplicate]
I am using Django and running a basic JS command for testing and manage to make it work if I wrap it such that the command start only after the whole document is ready or if I wrap the command between <script> tag inside the html directly, but not if I use a JS block tag and call the JS command. Why ? In more detail, say I have an html template and inside that template I have the js tag: {% block js %} <script src="{% static 'app/js/basic.js' %}"></script> {% endblock %} inside basic.js, this works: document.addEventListener('DOMContentLoaded', function(){ document.getElementById('js-table').style.height = "50px"; }); but this doesn't: document.getElementById('js-table').style.height = "50px"; and returns TypeError: document.getElementById(...) is null if I include a console.log, it prints correctly so the call to basic.js file works if I add the script below directly in the html it works: <script> document.getElementById('js-table').style.height = "50px"; </script> -
Undefined variable error during splitting views.py into modules - Django
My codes in views.py becomes larger day by day, and now I want to split it into modules. But I have trouble with variables. Problem is in that I don't where should I declare variables, or import built-in modules: in my custom module, or views.py. Here is my codes: views.py: @login_required(login_url='sign_in') def result(request): find_by_fives() context = { 'last_uploaded': last_uploaded, 'words_count': words_count, 'characters_count': characters_count } return render(request, 'result.html', context) find_by_fives.py(is my custom module): import glob from .models import OriginalDocument from django.shortcuts import render def find_by_fives(): last_uploaded = OriginalDocument.objects.latest('id') original = open(str(last_uploaded.document), 'r') original_words = original.read().lower().split() words_count = len(original_words) open_original = open(str(last_uploaded.document), "r") read_original = open_original.read() characters_count = len(read_original) path = 'static/other_documents/doc*.txt' files = glob.glob(path) Error: NameError: name 'last_uploaded' is not defined Note: This is not my entire view, all I want to know is just where should I declare context, variables, and imports. -
Best way to access reverse relation's attributes
I have these three models : MenuItem, Subs and Pizzas Both Subs and Pizzas have a foreign relation on MenuItem, for example : menuItem = models.ForeignKey('MenuItem', related_name='pizza', on_delete=models.CASCADE) Moreover, both Subs and Pizzas have a @property price() property. I would like to access this price property from the MenuItem, in order to be able to compute the price of an order. What would be the best way to implement this ? I have thought about defining a price() property in MenuItem, but then how do I access the reverse relation in order to retrieve the price, considering there may be multiple reverse relations ? Do I need to check every possible reverse relations, to find one that is not Null, and then access the price ? Thank you -
Authntication finally failed error on AWS ElasticSearch Service
I'm trying to upgrade a Django application from using AWS ElasticSearch 2.3 to 7.4 (and upgrade the Django packages at the same time). I have it running locally, but when I attempt to run with AWS ElasticSearch7.4 I get the following Traceback Traceback (most recent call last): File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/henry/Documents/Sites/Development/autumna2/autumna/src/search/views.py", line 169, in name_suggestions field='name_suggestion', File "/home/henry/Documents/Sites/Development/autumna2/autumna/src/search/views.py", line 129, in search_suggestions data = sqs.execute(ignore_cache=True).to_dict()['hits']['hits'] File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/elasticsearch_dsl/search.py", line 698, in execute **self._params File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 92, in _wrapped return func(*args, params=params, headers=headers, **kwargs) File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/elasticsearch/client/__init__.py", line 1627, in search body=body, File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/elasticsearch/transport.py", line 362, in perform_request timeout=timeout, File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 248, in perform_request self._raise_error(response.status, raw_data) File "/home/henry/Documents/Sites/Development/autumna2/env/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 244, in _raise_error status_code, error_message, additional_info elasticsearch.exceptions.AuthenticationException: AuthenticationException(401, 'Authentication finally failed') I am using django-elasticsearch-dsl so I've simply declared the host within settings.py (this is a straight replacement of what I had before) with ELASTICSEARCH_DSL = { 'default': { 'hosts': 'https://search-elastic7-zoqohjbiedz2ozmthfi4a3ccm4.eu-west-2.es.amazonaws.com', # I've changed this string }, } I'm using IAM authentication and I've given the IAM account full access to all my ElasticSearch …