Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django.core.exceptions.FieldError: Cannot resolve keyword 'content_type' into field. Choices are: id
I have below classes definition: class A(models.Model): created_time = models.DateTimeField(default=now, null=True, blank=True) t = GenericRelation(T, object_id_field='object_id', content_type_field='content_type', related_query_name='a') class B(A): state_path = models.CharField(max_length=256, blank=True, verbose_name="State Path") f = GenericRelation(F, content_type_field='content_type', object_id_field='object_id', related_query_name='b') class C(B): choice = models.BooleanField(default=False, verbose_name="Enabled") class T(models.Model): created_time = models.DateTimeField(auto_now_add=True, verbose_name="Created Time") # GenericForeignKey fields content_type = models.ForeignKey(ContentType, null=True, blank=True, on_delete=models.DO_NOTHING) object_id = models.PositiveIntegerField(null=True, blank=True) a = GenericForeignKey('content_type', 'object_id') class E(models.Model): username = models.CharField(max_length=128, verbose_name="Username") key = models.TextField(blank=True, verbose_name="Key") class F(E): content_type = models.OneToOneField(ContentType, on_delete=models.CASCADE) object_id = models.PositiveIntegerField() b = GenericForeignKey('content_type', 'object_id') c = C.objects.get(pk=c_id) c.delete() It returned error: django.core.exceptions.FieldError: Cannot resolve keyword 'content_type' into field. Choices are: id I don't quite get it why... as C doesn't have content_type, and T has on_delete=models.DO_NOTHING for its content_type. Please help correct. Thanks. -
Django request returning null?
So I'm building a chatbot withing Django using chat GPT and I'm following this tutorial https://www.youtube.com/watch?v=qrZGfBBlXpk anyway I don't see any difference in my code yet I'm running into a peculiar problem when I request from my html mile during the message sending process it returns null from the ''chatbot'' def chatbot(request): if request.method == 'POST': message = request.POST.get('message') response = message return JsonResponse({'message': message, 'response': response}) return render(request, 'chatbot.html') whats even weirder is when I console log the message in the JS messageForm.addEventListener('submit', (e) => { e.preventDefault(); const message = messageInput.value.trim() console.log('Message:', message) It shows up in the log? but somewhere along the line it returns null? I noticed when I used the davinci model and the chat would respond but only with nonsense which to me implied it wasnt actually getting MY message it was getting null and returning nonsense this Is the rest of the JS const messageItem = document.createElement('li'); messageItem.classList.add('message', 'sent'); messageItem.innerHTML = `<div class="message-sender"> <div class="message-sender" <b>You<b> </div> <div class="message-content"> ${message} </div> </div>`; messageList.appendChild(messageItem); messageInput.value = ''; const csrftoken = document.querySelector('[name=csrfmiddlewaretoken]').value; fetch('', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urleencoded', 'X-CSRFToken': csrftoken }, body: new URLSearchParams({ 'csrfmiddlewaretoken': csrftoken, 'message': message }) }) .then(response => response.json()) .then(data … -
Django template language is not recognized
I am working on a Django projcet. Yesterday when I left the project I didn't have any problems. Today when I opend the project my {% load static %} was gray, and the next line which is "<!doctype html>" gives me "Unexpected tokens". My project works fine except the templates. I work in a virtual envirment, have my project on github: https://github.com/FREDYKRUGE/Mist2.git. P.S I work with PyCharm proffesional I tried installing all the dependecies again, they were all satisfied, tried activating the venv, it was okay. My docker is up and running. -
Uploading images using forms in Django
I need help. Learning Django at the moment. Doing a simple (for now) project which is basically a site about film photocameras: it contains information, relations between cameras and films... You get the idea. I have created two forms to create a new entry for camera and for film. Here is the models to start with: class Camera(models.Model): ref_to_topic=models.ForeignKey(Topic, on_delete=models.CASCADE) ref_to_brand=models.ForeignKey(Brand, on_delete=models.CASCADE) camera_name=models.CharField(max_length=255) camera_info=models.TextField(null=True, blank=True) camera_image=models.ImageField(upload_to='site_media/camera_images/', null=True, blank=True) when_appeared_date=models.DateField(null=True, blank=True) when_appeared_year=models.IntegerField(null=True, blank=True) when_disappeared=models.DateField(null=True, blank=True) when_disappeared_year=models.IntegerField(null=True, blank=True) when_added=models.DateTimeField(auto_now_add=True) when_updated=models.DateTimeField(auto_now=True) owner = models.ForeignKey(User, on_delete=models.CASCADE, default=1) class Meta(): verbose_name_plural='cameras' def __str__(self): return f"{self.camera_name} - {self.camera_info[:25]}" class Film(models.Model): ref_to_topic=models.ForeignKey(Topic, on_delete=models.CASCADE) ref_to_brand=models.ForeignKey(Brand, on_delete=models.CASCADE) film_name=models.CharField(max_length=255) film_info=models.TextField(null=True, blank=True) film_image=models.ImageField(upload_to='site_media/film_images/', null=True, blank=True) when_added=models.DateTimeField(auto_now_add=True) when_updated=models.DateTimeField(auto_now=True) owner = models.ForeignKey(User, on_delete=models.CASCADE, default=1) class Meta(): verbose_name_plural='films' def __str__(self): return f"{self.film_name} - {self.film_info[:25]}" And here is the forms to full this models using browser: class CameraForm(forms.ModelForm): class Meta: model = Camera fields = ['camera_name', 'camera_info', 'when_appeared_date', 'when_appeared_year', 'when_disappeared', 'when_disappeared_year', 'ref_to_topic', 'ref_to_brand', 'owner', 'camera_image'] labels = { 'camera_name': 'Camera', 'camera_info': 'Info', 'when_appeared_date': 'Started on the market (exact date, can be null)', 'when_appeared_year': 'Strarted on the market (exact year, can be null)', 'when_disappeared': 'When the sales stopped (exact date, can be null)', 'when_disappeared_year': 'When the sales stopped (exact year, can be null)', 'ref_to_topic': 'refered to … -
Problem with Trio package when installing pymongo in my project
i have a django project that runs on ubuntu 20.04 version. i use selenium versio 4.1.5 . the selenium package has the trio package as a dependecy (version 0.22.2). until i added pymongo version (4.4.1) to my project everything worked fine. when installing it i get the following error : Traceback (most recent call last): File "mypath/checknet-api/./manage.py", line 26, in <module> execute_from_command_line(sys.argv) File "mypath/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 381,in execute_from_command_line utility.execute() File "mypath/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "mypath/venv/lib/python3.9/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "mypath/venv/lib/python3.9/site-packages/django/apps/registry.py", line 122, in populate app_config.ready() File "mypath/<innerpath>/apps.py", line 8, in ready import checknet.main.signals File "mypath/<innerpath>//signals.py", line 6, in <module> from .tasks import execute File "mypath/<innerpath>/tasks.py", line 7, in <module> from .bots import ( File "mypath/<innerpath>/fbi_crawler.py", line 2, in <module> from pymongo import MongoClient File "/mypath/venv/lib/python3.9/site-packages/pymongo/__init__.py", line 92, in <module> from pymongo.mongo_client import MongoClient File "mypath/venv/lib/python3.9/site-packages/pymongo/mongo_client.py", line 61, in <module> from pymongo import ( File "mypath/venv/lib/python3.9/site-packages/pymongo/uri_parser.py", line 32, in <module> from pymongo.srv_resolver import _HAVE_DNSPYTHON, _SrvResolver File "mypath/venv/lib/python3.9/site-packages/pymongo/srv_resolver.py", line 21, in <module> from dns import resolver File "mypath/venv/lib/python3.9/site-packages/dns/resolver.py", line 30, in <module> import dns._ddr File "mypath/venv/lib/python3.9/site-packages/dns/_ddr.py", line 12, in <module> import dns.nameserver File "mypath/venv/lib/python3.9/site-packages/dns/nameserver.py", line 5, in <module> import dns.asyncquery File "mypath/venv/lib/python3.9/site-packages/dns/asyncquery.py", line 38, in <module> from dns.query … -
Python django Usermodel extending to custom user model
The problem is i need an extra field to add my Django usermodel via a custom user model called 'is_admin' so ,this is the code i added to model class CustomUser(AbstractUser): is_admin = models.BooleanField(default=False) but i registered this model to admin.py when i tried to add a user using django admin page the password stores as plain not hashing hos to solve this problem AUTH_USER_MODEL = 'cAdmin.CustomUser' i've already changed the default user model and admin.py from django.contrib import admin from .models import CustomUser,Priority from django import forms from django.contrib.auth.admin import UserAdmin # Register your models here. admin.site.register(CustomUser) admin.site.register(Priority) -
not showing HttpResponse in django python
`settings.py `INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'sample' ] ` sample/views.py from django.shortcuts import render from django.http import HttpResponse def hello(request): return HttpResponse("hello world") mainapp/ urls.py from django.contrib import admin from django.urls import path from sample import views urlpatterns = [ path('hello/',views.hello), path('admin/', admin.site.urls) ] but when i run python manage.py runserver it is not shoing the 8000/hello/ page -
Initialize Model w Foreign Keys in Django
I have a Model that represents a card. A card will only ever have two card faces, the front and the back. The card faces contain a background image, with a number of related data fields containing strings and positions to render the strings on it. I want to have the base image as a file and then render the strings onto it so I can print them out through a printer. I've done DB modelling before but I don't consider myself an expert. I also tend to overthink things so I might just be driving myself crazy when there's a simple solution to do what I want. My googleFu is mostly just leading me around in circles. I want to prevent anyone from trying to add or delete the card faces. I also want to pre-populate the object so that it only ever has a front and back. The relationship for Card to CardFace is one to exactly two. But I'm having trouble trying to figure out how to do this model. I've actually got the rendering part working. It's more a matter of when it should be done. I want to save the original unchanged background image so … -
In Django, how to use HTMX or Django-Autocomplete-Light for a dependent combobox? (using the same database table)
I am using for the first time, in Django, HTMX and Django-Autocomplete-Light a try. I've read tutorials on the web and created test projects, but I can't get what I want. Most of the tutorials use ForeignKey and create two tables (that's easy), while I have all the data on the same table. I want to use only one table. Could someone show me the code of how to achieve this? I prefer HTMX, but Django-Autocomplete-Light is also fine. Choose one of the two, both are fine ID | COUNTRY | DEPARTURE | DESTINATION | | france | paris | lyon | | france | marseilles| grenoble | | spain | madrid | barcelona | | spain | seville | malaga | In the main combobox, called country, there are: Spain and France. In the second combobox are the trips for each country, made up of two columns. I would like to see them separated by a dash (departure-destination), for example: Madrid-Barcelona, Seville-Bilbao CMBX1 CMBX2 france > paris-lyon marseille-grenoble spain > madrid-barcelona seville-malaga -
Auto Deploy Django with GitHub Actions CI/CD And Configure Gunicorn & Nginx
I want to deploy a Django Web App in cloud server. I already have the project. But deploying it using CI/CD and cloud server is tough. I want to use GitHub Actions for CI/CD and in my cloud server, I want to configure Gunicorn and Nginx. Can someone help me with step by step process to do all these? -
How to do an authentication between django and nextjs 13?
Can I build authentication system between django and nextjs 13 ? If yes, How can I do that ? I'm really stuck I wanted to use JWT token based authentication but because nextjs 13 uses server components I didn't know how and where can I store access and refresh tokens. Thanks.. -
Django app in docker compose seems to be getting brute forced url requests with a docker ip
I have a cookiecutter-django based setup with docker-compose, with a mailing service from Mailjet with Anymail on a VPS on Vultr for staging. I use traefik as a reverse-proxy. I occasionally get emails from the app for 404 errors when I or my partner tries an invalid link. But since 3 days ago, I have been gettings hundreds of emails a day for 404 errors with url paths that can be considered usual defaults for many different frameworks such as /login, /Home/Login, /static/style.css, etc. That in itself would have been easy to fix, if Traefik was the container receiving the requests. No, the emails all say I'm getting the request from 172.19.0.08, whereas my project (nothing else is running in this VPS to my understanding) uses 172.20.0.X as the network. I even set up a RateLimit middleware in traefik but it was pointless since the requests never go through traefik. I am not very good at networks so I do not know how to identify what is happening here. Django logs don't show the requests either to my understanding although I don't have a very detailed django logging config set up (used default from cookiecutter with DEBUG as the level). … -
Password is not hashing while adding customuser @ django admin site
class CustomUser(AbstractUser): is_admin = models.BooleanField(default=False) objects = CustomUserManager() class CustomUserManager(BaseUserManager): def create_user(self, username, password=None, **extra_fields): if not username: raise ValueError('The username must be set') print(password) user = self.model(username=username, **extra_fields) user.set_password(password) # This hashes the password user.save(using=self._db) return user i just need to add extra field in this custom model but whenever i tried to add this user by django admin site the password is stored as plain the problem is the CustomUserManager is not being called -
Is it possible to create shopify payment app in django
I need to create a payment app for shopify with offsite payment app extension with Django. I have read the Documentation for payment app but the payment API it is written for nodeJS. Is it possible to implement the payment app in Django?. -
How to use naturalspeech2-pytorch convert text to audio
I'm developing the audio service with whisper, Ghat_GPT and naturalspeech2-pytorch. What I need to solve is to implement the naturalspeech2-pytorch python module to convert the text to audio. I'm lacked the data. Which python version Do I need to do. please help me. I tried naturalspeech2-pytorch to convert text to audio. -
What are some Alternatives to ChatGPT API
I have resorted to using stack overflow, I am looking for free API's that are similar to chatGPT's me and a team are building a Django application and are looking to integrate it with chatGPT4free until we realized that it wasnt an API, any free API's out there for that? -
Whats the purpose of the dot in this line: from . import views
I'm looking at the Django documentation, and in some point, they import views with this line: from . import views. It works, but... what's the purpose of the dot??? from . import views, the line works but i don't know why -
Why serializer data isn't displayed by foreign key in view?
I need to show user info in my post as nested json. Models: Profile # Django from django.db import models class Profile(HelperModel): """ User Profile UserProfile provides the principal fields for the user participation in addition using proxy model that extends the base data with other information. """ user = models.OneToOneField( 'authentication.User', on_delete=models.CASCADE) avatar = models.ImageField( upload_to='authentication/pictures/users', blank=True, null=True ) def __str__(self) -> str: """Return username""" return self.user.username Post # Django from django.db import models from zivo_app.apps.authentication.models.profiles import Profile class Post(HelperModel): ''' Implements the logic of post, this is a main model, inside save all the field logic for their correctly works. Extends authentication lawyer models. ''' title = models.CharField(max_length=130) error_code = models.CharField(max_length=150, blank=True) brief = models.TextField(max_length=250) avatar = models.ImageField( upload_to='blog/pictures/cover', blank=True, null=True ) # FK user = models.ForeignKey( Profile, related_name='profiles', on_delete=models.CASCADE, verbose_name=("User Profile") ) Serializers: ProfileSerializer """Profile serializer.""" # Django REST Framework from rest_framework import serializers # Models from ..models.profiles import Profile class ProfileModelSerializer(serializers.ModelSerializer): """Profile model serializer.""" class Meta: """Meta class.""" model = Profile fields = '__all__' PostSerializer ''' List all post in home level ''' # Django REST Framework from rest_framework import serializers # Models from ...models.post.post import Post class ListPostSerializer(serializers.ModelSerializer): profiles = serializers.StringRelatedField(many=True) class Meta: model = … -
Is there a special way of adding Django message to current template with multiple forms and calls to same page?
I have a message template: messages.html {% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}> {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}Important: {% endif %} {{ message | safe }} </li> {% endfor %} </ul> {% endif %} that I include in my templates: add_recipient.html {% block content %} {% include 'myapp/messages.html' %} <div class="doc"> <h2>Add Recipient</h2> <a class="btn btn-dark btn-lg" href="{% url 'myapp:recipient_list' 'A' %}">Back To List</a> <div class="form"> <form method="post"> {% csrf_token %} <table class="form form-table" style="font-size: x-large"> {{ recipient }} {{ address }} {{ demographics }} {% if person_forms %} {{ person_forms }} {% endif %} </table> <div class="row d-flex justify-content-center m-4"> <button class="btn btn-primary btn-lg " type="submit">Add Recipient</button> </div> </form> </div> </div> {% endblock content %} and: edit_recipient.html {% block content %} {% include 'myapp/messages.html' %} <div class="doc"> <h2>Edit Recipient Details</h2> <div class="container-fluid m-0"> <div class="row "> <div class="col-lg"> <a class="btn btn-dark btn-lg" href="{% url 'myapp:recipient_detail' recipient_id=recipient_id back_to=back_to %} ">BACK</a> </div> </div> </div> <div class="d-flex flex-row"> <div class="d-flex flex-column mx-auto" > <form method="post"> {% csrf_token %} <table class="form form-table" style="font-size: x-large"> {{ recipient_form }} {{ address_form }} {{ demo_form}} {{ formset }} </table> <button class="btn … -
why throw me this error when i try to show my api from django data in react "products undefined". In the console show me the data but not show
`import logo from '../logo.svg'; import SingleProduct from './SingleProduct' import { useState, useEffect } from 'react'; function AllProducts() { const [products, setProducts] = useState([]) useEffect(() => { fetchData('http://127.0.0.1:8000/api/products/'); }); function fetchData(baseurl) { fetch(baseurl) .then((response) => response.json()) .then((data) => setProducts(data.results)); } return ( <section className="container mt-4" > {/* Latest Products */} <h3 className="mb-4">All Products</h3> <div className="row mb-4" > { products.map((product) => <SingleProduct product={product} />) } </div> <nav aria-label="Page navigation example"> <ul className="pagination"> <li className="page-item"><a className="page-link" href="#">Previous</a></li> <li className="page-item"><a className="page-link" href="#">1</a></li> <li className="page-item"><a className="page-link" href="#">2</a></li> <li className="page-item"><a className="page-link" href="#">3</a></li> <li className="page-item"><a className="page-link" href="#">Next</a></li> </ul> </nav> </section> ) } export default AllProducts;` -
How do I make a custom user model the auth_user database?
I added this line in my settings.py file in order to make a custom User model the auth_user database: AUTH_USER_MODEL = 'main.User' (main is the name of one my apps and it contains all of the models). But I later found out that I should have done this before the initial migration so when I tried to integrate Google Authentication in the admin page I received this error that stated that my auth_user table was empty (something about it not having any records with an id of 1). So I tried deleting the migrations and returning the database to its state before the migrations but I always had an error like this: ValueError: The field socialaccount.SocialAccount.user was declared with a lazy reference to 'main.user', but app 'main' isn't installed. I tried fixing this by following the adive on this article and cleared my postgresql database along with migration files and pycache. After this I tried to makemigrations and received this error: ValueError: The field socialaccount.SocialAccount.user was declared with a lazy reference to 'auth.user', but app 'auth' isn't installed.. And then this error when I tried to migrate: django.db.utils.ProgrammingError: relation "main_user" does not exist. I have tried searching for solutions but … -
Connecting a Django Project to an AS400 IBM iSeries System
I have been following the github documentation referred to from the official IBM website to use ibm_db and ibm_db_django packages to connect my Django application to an AS400 iSeries system. But I have constantly been running into the same error after trying to run "python3 manage.py runserver". django.core.exceptions.ImproperlyConfigured: 'ibm_db_django' 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', 'postgresql', 'sqlite3' My settings.py file within my django app is as follows INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.flatpages', 'django.contrib.redirects', 'ibm_db_django', ] DATABASES = { 'default': { 'ENGINE' : 'ibm_db_django', 'NAME' : 'XXXXX', 'USER' : 'XXXXX', 'PASSWORD' : 'XXXXX', 'HOST' : 'XXXXX', 'PORT' : '####', 'PCONNECT' : True, #Optional property, default is false } } Also my pip list dependencies within the virtual environment has the correct versions of python, Django, and the packages mentioned above to be compatible with each other so I am not sure why I am still running into this error. (env) floriskruger4@Floriss-MBP ibmi_test % pip list Package Version ----------------- -------- asgiref 3.7.2 Django 3.2 ibm-db 3.1.4 ibm-db-django 1.5.2.0 pip 22.0.4 pytz 2023.3 regex 2023.6.3 … -
Why does CSRF fail even though there is a CSRF token in Django?
I am building a login form with Django and it shows a CSRF error. The template is this: <html> <head> <title>TaxNow</title> <meta charset="utf-8"> </head> <body> <script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script> <header> </header> <script> $("document").ready(function () { $("header").load("static/header.html"); }) </script> <div id="loginbox"> <h3>Log In to Access TaxNow</h3> <div id="invalidCredentials"></div> <form action="http://127.0.0.1:8000" method="POST"> <label>Username:</label> <input type="text" id="uname" name="uname"><br><br> <label>Password:</label> <input type="password" id="pass" name="pass"><br> <button id="login" type="submit">Log In</button></br> {% csrf_token %}</form> <a href="signup.html">Sign Up</a><br> <a href="forgotCredentials.html">Forgot Username/Password?</a> <script> params = new URLSearchParams(location.search); params.get('name'); var GET = params.getAll('invalidCredentials') if (GET[0] == "true") { $("#invalidCredentials").innerHTML = "Invalid username or password." } </script> </div> </body> </html> The views.py function is like so: def logIn(request): if not User.is_authenticated: return render(request, "taxnow/app/login.html") urls.py: from django.urls import path from . import views urlpatterns = [ #other paths path('startFile', views.logIn, name="logIn") ] Something intresting is that there is a cookie here: I have used the @csrf_exempt decorator but IDK whether this is safe. Any thoughts? -
Django -> Git -> Heroku Deployment Failure
Trying to deploy Django app to Heroku but receiving the below error. Tried twice - same error. Pushing from laptop to Heroku. No branch git sites. Python 3.11.4 is on my laptop and what is used by Heroku. I have the necessary prep files required by Heroku in the root directory: procfile requirements.txt settings.py git push heroku master Enumerating objects: 11095, done. Counting objects: 100% (11095/11095), done. Delta compression using up to 8 threads Compressing objects: 100% (7766/7766), done. Writing objects: 100% (11095/11095), 17.60 MiB | 9.29 MiB/s, done. Total 11095 (delta 3916), reused 8495 (delta 2215), pack-reused 0 remote: Resolving deltas: 100% (3916/3916), done. remote: Updated 6372 paths from 4b90c76 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-22 stack remote: -----> Determining which buildpack to use for this app remote: -----> Python app detected remote: -----> **No Python version was specified. Using the buildpack default: python-3.11.4** remote: To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes remote: -----> Installing python-3.11.4 remote: -----> Installing pip 23.1.2, setuptools 67.8.0 and wheel 0.40.0 remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: Collecting asgiref==3.6.0 (from -r requirements.txt (line 1)) remote: Downloading asgiref-3.6.0-py3-none-any.whl (23 kB) remote: … -
bring the customer id from auto search box and then redirect to it the customer update page
I have a Django project. it has the functionality to create a customer and its working fine.I have added the auto search box in the same template to search already created customer. when i enter word its suggesting the names already saved in the database. but when i clicked a name its **displaying in the search box as [object object] not the correct name **. and I created button to selected customer to update . but when i clicked the button its saying "Please select a customer from the autocomplete list" i need to find whats the problem in my code. I need to correctly show the selected result from auto suggest search box and when i clicked the update button it should redirect to the customer update page. here is the html code of my auto complete search box" `<div class="col-md-6 mx-auto"> <div id="autocomplete" class="autocomplete"> <input class="autocomplete-input" /> <ul class="autocomplete-result-list"></ul> </div> <button id="update-customer-button" type="button" onclick="redirectToUpdateCustomer()">Update</button> </div> </div>"` and here is my JavaScript for the auto complete search and redirecting to the update page" `const selectedCustomerId = null; // Existing Autocomplete setup new Autocomplete('#autocomplete', { search: input => { console.log(input); const url = `/master/get_customers/?search=${input}`; return new Promise(resolve => { fetch(url) …