Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to popup the alert - Django template
I have wrote the template for user input the info , each user will have the separate password. I would like to validate the password when they input , if the password is incorrect they will got the popup message said "wrong password .." or sth like that. I tried to import messages library, however it doesn't work correctly, could you please help assist ? below is my code: views.py from .models import Register1 @csrf_exempt def reg(request): if request.method == 'POST': if request.POST.get('password') =="Password": print(request.POST.get('password')) if request.POST.get('phone') and request.POST.get('name') and request.POST.get('email'): post=Register1() post.phone= request.POST.get('phone') post.name= request.POST.get('name') post.email= request.POST.get('email') post.save() return render(request, 'posts/reg.html') else: print(request.POST.get('password')) messages.add_message(request, messages.INFO, 'Wrong Password') return render(request,'posts/reg.html') else: return render(request,'posts/reg.html') templates/posts/reg.html <meta charset="UTF-8"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <div class="container mt-3"> <body> <div class="col-9"> <!-- <h2>Input your password to continue proceed</h2> password: <input id = "pwd" type="password" name="password"/><br/> <div class="col-3 "> --> <!-- <button class="btn btn-primary" onclick="validate()">proceed</button> </div> --> </div> <div class="col-6 mt-3"> <form action="" method="POST"> {% csrf_token %} <h2>Input your password to continue proceed</h2> password: <input id = "pwd" type="password" name="password"/><br/> <div class="col-3 "> Phone: <input type="text" name="phone"/><br/> <!-- Name: <br/> <textarea cols="35" rows="8" name="name"> </textarea><br/> --> Name: <input type="text" name="name"/><br/> Email: <input type="text" name="email"/><br/> <input … -
Failed to load image at '/images/logo.png': timeout: timed out in html to pdf by weasyprint
<img id="pdf-logo-2" src="{% static 'assets_landing/images/logo.png' %}" alt="#" /> I face issue when render pdf from html. In weasyprint log, it show Failed to load image at '/images/logo.png': timeout: timed out -
How I can update nested relationships
I'm learn DRF, trying write simple monitoring system for computers. With client I havent problem, but with server have one - UPDATE foreign key. Code - https://pastebin.com/HgKXKNh0 How I can known pk for Disk and NetAdapter in for disk_data in disks_data: Disks.objects.update(client=instance, **disk_data) for adapter_data in net_adapter_data: NetAdapter.objects.update(client=instance, **adapter_data) def create(self, validated_data) from https://www.django-rest-framework.org/api-guide/relations/#writable-nested-serializers, I tried to do the same update, but it didn't work. -
AWS ElasticBeanstalk LoadBalancer Config Not Linking my aplication to my domain
I created an aplication but Its is not linked to my domain exp: "site.com", "www.site.com", when I access it I get: Note: my apllication status is "ok" EI went to EC2 - LoadBalancer, And copied the instance ID, then I went to my Hoster, created a CNAME "api" and put the instance value, when I acessed "api.site.com" It worked, my aplication was linked to my domain(but not as https), but why isn't "site.com" and "www.site.com" linked? and I set the following configs: I created a key pair when I did EB init( I dont know for what it's for) Type a keypair name. (Default is aws-eb): SSH-Django_store Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\kayna\.ssh\SSH-Django_store. Your public key has been saved in C:\Users\kayna\.ssh\SSH-Django_store.pub. The key fingerprint is: SHA256:Int9QZ2czLsVCXAJTaprHmOMhuCAq4R8fGK2mKuelFU SSH-Django_store The key's randomart image is: and then I created the LoadBalancer in ElasticBeanstalk: WHY is my loadbalancer different from the tutorial i'm watching in youtube? the title is "Modify Classic LoadBalancer" the videos I watch have a different loadbalancer pagar My domain: My domain with "api" as subdomain from when I copied the instance from EC2 and … -
django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)")
i was trying to connect to mySQL DB but i got this error although the server is running as shown: and here's my connection data: DB_HOST='127.0.0.1' DB_NAME='trustline' DB_USER='root' DB_PASSWORD='' DB_PORT=3306 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': config('DB_NAME'), 'USER': config('DB_USER'), 'PASSWORD': config('DB_PASSWORD'), 'HOST': config('DB_HOST'), 'PORT': '3306', 'OPTIONS': { 'sql_mode': 'STRICT_TRANS_TABLES', 'charset': 'utf8mb4' }, } } what should be done? -
Property field not appearing in django serializer
I have a property inside a Django model, I have to show it inside the serializer. I put the field inside the serializer, but it's not coming up in the response. class Example(models.Model): field_1 = models.ForeignKey( Modelabc, on_delete=models.CASCADE, null=True, related_name="abc" ) field_2 = models.ForeignKey( Modelxyz, on_delete=models.CASCADE, null=True, related_name="xyz", ) name = models.CharField(max_length=25, blank=True) @property def fullname(self): if self.name is not None: return "%s%s%s" % (self.field_1.name, self.field_2.name, self.name) return "%s%s" % (self.field_1.name, self.field_2.name) Serializer is like this: class ExampleSerializer(serializers.ModelSerializer): fullname = serializers.ReadonlyField() class Meta: model = OnlineClass fields = [ "id", "fullname",] When I call the get API for this, the fullname is not being displayed in the api response. What is the issue? -
(Django RF) Unable to set the 'to_field' to ForeignKey model
I have four model like the code below: class Sample(models.Model): sample_ID = models.CharField(max_length=10, unique=True) def __str__(self): return str(self.sample_ID) class Image(models.Model): image_ID = models.CharField(max_length=50, primary_key=True, unique=True) image_sample = models.ForeignKey(Sample, on_delete=models.CASCADE, related_name='image_sample') image = models.ImageField(upload_to='images') def __str__(self): return str(self.image_ID) class Label(models.Model): AI_sample = models.ForeignKey(Sample, on_delete=models.CASCADE, related_name='AI_sample') AI_defect = models.BooleanField() def __str__(self): return str(self.AI_sample) class Manual(models.Model): manual_sample = models.ForeignKey(Sample, on_delete=models.CASCADE, related_name='manual_sample') manual_image = models.ForeignKey(Image, on_delete=models.CASCADE, to_field='image_ID') manual_defect = models.BooleanField() def __str__(self): return str(self.manual_sample) Manual is ForeignKey to Sample & Image. and Image is also ForeignKey to Sample. Now I have customized an image_ID field for the to_field in manual_image so that I can reference it using my custome field. However, when I try to do the same thing for manual_sample and sample_ID, the manual_sample will become null value like this: sample: [ { "id": 1, "sample_ID": "a000001", "AI_sample": [], "manual_sample": [] } ] manual_sample: [ { "id": 3, "manual_sample": null, "manual_image": "p01", "manual_defect": true }, { "id": 5, "manual_sample": null, "manual_image": "p02", "manual_defect": false } ] For now, my API endpoint look like this: [ { "id": 1, "sample_ID": "a000001", "AI_sample": [], "manual_sample": [ { "id": 3, "manual_sample": 1, "manual_image": "p01", "manual_defect": true }, { "id": 5, "manual_sample": 1, "manual_image": "p02", "manual_defect": false … -
FATAL [2022-05-19 03:22:16] [/tmp/smallday_judger/src/child.c:41]Error: System errno: Operation not permitted; Internal errno: SETRLIMIT_FAILED
i have been running an online compiler i get this error in docker image compile.log file.. in UI i get Compiler error.after i check log file i get this FATAL [2022-05-19 03:22:16] [/tmp/smallday_judger/src/child.c:41]Error: System errno: Operation not permitted; Internal errno: SETRLIMIT_FAILED I am using docker_judger, AWS linux ami reference link:- https://opensource.qduoj.com/#/onlinejudge/guide/deploy -
ModuleNotFoundError: No module named 'django_heroku' even though django-heroku is installed
I am trying to run python manage.py shell_plus --notebook from my project directory, within a virtual environment. This command was previously working, but now no longer, and I believe the issue must be with some package version conflicts. I have a virtual environment with the following packages installed: Package Version -------------------- ----------- appnope 0.1.3 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 asgiref 3.5.2 asttokens 2.0.5 attrs 21.4.0 backcall 0.2.0 backports.zoneinfo 0.2.1 beautifulsoup4 4.11.1 bleach 5.0.0 cffi 1.15.0 debugpy 1.6.0 decorator 5.1.1 defusedxml 0.7.1 dj-database-url 0.5.0 Django 4.0.4 django-extensions 3.1.5 django-heroku 0.3.1 django-on-heroku 1.1.2 entrypoints 0.4 executing 0.8.3 fastjsonschema 2.15.3 gunicorn 20.1.0 importlib-resources 5.7.1 ipykernel 6.13.0 ipython 8.3.0 ipython-genutils 0.2.0 ipywidgets 7.7.0 jedi 0.18.1 Jinja2 3.1.2 jsonschema 4.5.1 jupyter 1.0.0 jupyter-client 7.3.1 jupyter-console 6.4.3 jupyter-core 4.10.0 jupyterlab-pygments 0.2.2 jupyterlab-widgets 1.1.0 MarkupSafe 2.1.1 matplotlib-inline 0.1.3 mistune 0.8.4 nbclient 0.6.3 nbconvert 6.5.0 nbformat 5.4.0 nest-asyncio 1.5.5 notebook 6.4.11 numpy 1.22.3 packaging 21.3 pandocfilters 1.5.0 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 pip 22.1 prometheus-client 0.14.1 prompt-toolkit 3.0.29 psutil 5.9.0 psycopg2 2.9.3 psycopg2-binary 2.9.3 ptyprocess 0.7.0 pure-eval 0.2.2 pycparser 2.21 Pygments 2.12.0 pyparsing 3.0.9 pyrsistent 0.18.1 python-dateutil 2.8.2 pyzmq 22.3.0 qtconsole 5.3.0 QtPy 2.1.0 scipy 1.8.1 Send2Trash 1.8.0 setuptools 49.2.1 six 1.16.0 soupsieve 2.3.2.post1 sqlparse 0.4.2 stack-data 0.2.0 … -
Django ORM filter with two __in
I'm having model with two field. product_ids_list = [1,2,3,4] selling_prices_list = [65, 89, 93] And length of product_ids_list and selling_prices_list are same. I want to perform below ORM filter for one product_id and it's corresponding selling price like this. product_instances = Product.objects.filter(product_id=product_ids_list[0], selling_price=selling_prices_list[0]).first() But how to do perform ORM filter with just one DB call with product_ids_list and it's corresponding selling_prices_list. product_instances = Product.objects.filter(product_id__in=product_ids_list, selling_price__in=selling_prices_list).first() (This isn't working in the expected way) -
Display only days on django template
I'm trying to display the difference between 2 giving dates on django, and i've managed to make it, but now i'm strugling to display only the days, without the time, is there any filter that i can use? My html template: <a href="{% url 'edit_contract' contract.id %}"> {% if contract.status == 'PN' %} {{ today |sub:contract.starting_date }} {% else %} TODO {% endif %} </a> My view: @login_required def contract_list(request): contracts = Contract.objects.filter(user=request.user) total_contracts_value = Contract.objects.filter(user=request.user).aggregate(sum=Sum('value'))['sum'] or 0 contracts_count = Contract.objects.filter(user=request.user).count() today = date.today() return render(request, 'list_contract.html', {'contracts': contracts, 'total_contracts_value': total_contracts_value, 'contracts_count': contracts_count, 'today':today}) My output: -
how to pass multiple optional parameter in Django views.py
I want to know how to write code efficiently when there are multiple if statements in one function in Django views.py. This function is about the stats, there is a table of 6 stats vertically in card format. five and six variable have different values depending on the parameter. def statistic(requests): one = Student.objects.filter(...) two = Teacher.objects.filter(...) three = Subject.objects.filter(...) four = Assignment.objects.filter(...) team_parameter = request.GET.get('team') if team_parameter == 'ALL': five = Student.objects.filter(...) else: five = Student.objects.filter(team=team_parameter, ...) option = request.GET.get('option') from = request.GET.get('from_date') to = request.GET.get('to_date') if option == 'total': six = Subject.objects.filter(...) else: six = Subject.objects.filter(register_date__gte=from, register_date__lte=to, ...) return render(request, 'stats.html', {'one': one, 'two': two, 'three': three, 'four': four, 'five': five, 'six': six}) When entering the statistics page, there is no value of request.GET, and parameters can be set in the drop down list from the 5 or 6 tables. And 'ALL' for table 5 and 'total' for table 6 are set as default values. And when I select another option in table 5 or 6, if the data of the table is changed, the contents of tables 1, 2, 3, and 4 do not disappear and the values should be continuously output. I don't know how to … -
Django with django_plotly_dash register admin panel
In my project django using dash, in panel admin is registered DJANGO PLOTLY DASH(image attachment),but I want to remove this. I don't have idea how do this. enter image description here -
django.db.utils.OperationalError: (1045, 'Plugin caching_sha2_password could not be
I'm trying to containerize my Django app with mysql and I get the following error when I try to run docker-compose up --build. Successfully tagged drosmokers_web:latest [+] Running 3/2 ⠿ Network drosmokers_default Created 0.1s ⠿ Container drosmokers-db-1 Created 0.3s ⠿ Container drosmokers-web-1 Created 0.1s Attaching to drosmokers-db-1, drosmokers-web-1 drosmokers-db-1 | 2022-05-19 02:09:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started. drosmokers-db-1 | 2022-05-19 02:09:40+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' drosmokers-db-1 | 2022-05-19 02:09:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started. drosmokers-db-1 | 2022-05-19T02:09:40.450429Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28) starting as process 1 drosmokers-db-1 | 2022-05-19T02:09:40.459416Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. drosmokers-db-1 | 2022-05-19T02:09:40.971548Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. drosmokers-db-1 | 2022-05-19T02:09:41.218218Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. drosmokers-db-1 | 2022-05-19T02:09:41.218279Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. drosmokers-db-1 | 2022-05-19T02:09:41.229850Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. drosmokers-db-1 | 2022-05-19T02:09:41.261835Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.28' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL … -
highlight.js not working on django website
I have a django website where I'd like to display blocks of code w/ syntax highlighting. I've installed highlight.js and per their instructions am injecting style and js into html, in this case in base.html: ... <link rel="stylesheet" href="{% static 'highlight/styles/default.min.css' %}"> <script src="{% static 'highlight/highlight.min.js' %}"></script> <script>hljs.highlightAll();</script> I then add code to some view using dash html components: ... html.Div([html.H3(title), html.Pre(html.Code(code, className=f'language-{lang}'))]) The code isnt't syntax highlighted. Not sure how to troubleshoot this. -
ValueError: The field socialaccount.SocialAccount.user was declared with a lazy reference to 'auth.user', but app 'auth' isn't installed
Does anyone know how to solve this error? ValueError: The field socialaccount.SocialAccount.user was declared with a lazy reference to 'auth.user', but app 'auth' isn't installed. -
Error making mutations for a many to many relation with graphene-django
I'm trying to make something with graphene-django but I'm having some issues with the many to many relations, I'm trying to create a relation between roles and permissions, according the documentation and some tutorials everything is "OK" with the code but when I open the graphql console to make a mutation for the intermediate table there's an error so, it's not completely "OK". This is how my code looks like Models: class Roles(models.Model): name = models.CharField(max_length=50) description = models.CharField(max_length=500) def __str__(self): return self.name class Permissions(models.Model): name = models.CharField(max_length=50) description = models.CharField(max_length=500) def __str__(self): return self.name class RolePermissions(models.Model): role = models.ForeignKey(Roles, on_delete=models.DO_NOTHING) permission = models.ForeignKey(Permissions, on_delete=models.DO_NOTHING) def __str__(self): return True Types: class RolesInput(graphene.InputObjectType): id = graphene.ID() name = graphene.String() description = graphene.String() class PermissionsInput(graphene.InputObjectType): id = graphene.ID() name = graphene.String() description = graphene.String() class Role_PermissionsInput(graphene.InputObjectType): id = graphene.ID() roleId = graphene.ID() permissionId = graphene.ID() Mutation class CreateRolePermission(graphene.Mutation): class Arguments: role_permission_data = Role_PermissionsInput(required=True) role_permission = graphene.Field(RolePermissionsType) @staticmethod def mutate(root, info, role_permission_data=None): role_permission_instance = RolePermissions( role =role_permission_data.roleId, permission=role_permission_data.permissionId, ) role_permission_instance.save() return CreateRolePermission(role_permission=role_permission_instance) I already have data into the DB to test the querys and everything is good and I can create both roles and permissions individually, but the relation between is having a … -
Django model rendering number instead of string
I'm creating a blog site with authors posting blogs, etc. The issue is with rendering the author's name, instead django is returning a number. My blog model: class Blog(models.Model): title=models.CharField(max_length=255) author=models.ForeignKey(User, on_delete=models.CASCADE) date_posted=models.DateTimeField(auto_now_add=True) body=models.TextField() def __str__(self): return self.title And my serializer: class Meta: model=Blog fields=('title', 'author', 'body', 'date_posted') However, in django rest framework it's rendering a number, when it should be the 'admin' user: [ { "title": "First Blog", "author": 1, "body": "Example blog text", "date_posted": "2022-05-18T23:55:21.529755Z" } ] A bit confused, since there's no error, it just isn't rendering 'admin'. Any help would help thanks. -
Doble initialization on django-bootstrap-modal-forms
I currently using this library on django https://github.com/trco/django-bootstrap-modal-forms I got this on my js script: function initializeBSModal(modalId) { const Modal = $(modalId); Modal.modalForm({ modalID: '#bs-modal', modalContent: '#bs-modal-content', modalForm: '#bs-modal-content form', formURL: Modal.data('form-url'), }); } Each time it is used it initialized correctly, but if in any instance it is called twice (e.g draw event on table), it initialized a second time, executing twice or more times on requesting GET to the View (only GET not on POST) Code example: {% block content %} <div id="bs-modal-create" class="" data-form-url="{% url 'create_item' %}"> CREATE </div> {% endblock %} {% block scripts %} <script> initializeBSModal('#bs-modal-create'); initializeBSModal('#bs-modal-create'); -> This causes 2 initialization, 2nd GET </script> {% endblock %} How may i only initialize not initialized modals?? -
how can I make python work in pycharm again
I was using Pycharm properly before, So I needed to install anaconda. Whilst trying to install anaconda, I had to delete all files or traces of my python for anaconda to be installed properly. Please how to get back to using Pycharm properly as I was before including continuing my Django project. because everywhere is just messed up. I don't know what to do or start from -
MDN Django TypeError: 'NoneType' object is not callable
In the code below, I have a book model, and I am trying to register that model along with the List Display with a decorator. Unfortunately, I am getting an error listed below, saying there is a TypeError with my Model List Display Class, where NonType object is not callable. I have looked into solutions, but haven't found any, so it would be nice to get some help. I am following MDN tutorial BTW, https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Admin_site. Thank you for helping! Book Model class Book(models.Model): title = models.CharField(max_length=200) author = models.ForeignKey('Author', on_delete=models.SET_NULL, null=True) summary = models.TextField(max_length=1000, help_text='Enter a brief description of the book') isbn = models.CharField('ISBN', max_length=13, unique=True, help_text='13 Character <a href="https://www.isbn-international.org/content/what-isbn' '">ISBN number</a>') genre = models.ManyToManyField(Genre, help_text='Select a genre for this book') def __str__(self): return self.title def get_absolute_url(self): return reverse('book-detail', args=[str(self.id)]) def display_genre(self): return ', '.join(genre.name for genre in self.genre.all()[:3]) display_genre.short_description = 'Genre' Book Model in Admin with List Display @admin.site.register(Book) class BookAdmin(admin.ModelAdmin): list_display = ('title', 'author', 'display_genre') Error class BookAdmin(admin.ModelAdmin): TypeError: 'NoneType' object is not callable -
Why am I getting a type error between two integers
I am trying to make the shopping cart of an e-commerce store and I've modelled the database and everything but I keep on getting a type error. Storefront/Models.py/Product from django.db import models class Product(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(max_length=200) price = models.DecimalFiled(max_digits=10, decimal_places=2) quantity= models.IntegerField(default=1) def __str__(self): return self.name Now I'm working on the shopping cart view to take quantity from users and to check if it is more than available goods. Cart/views.py (jumping some codes) from Storefront.models import Product try: quantity=int(request.data['quantity']) if quantity > Product.quantity: raise NotAcceptable('quantity more than available in stock') The error code I'm getting is: TypeError: '>' not supported between instances of 'int' and 'DeferredAttribute' The quantity being inputed is being converted to an integer and Product.quantity is an integerfield so what am I doing wrong? -
Overriding .update() and getting "... fields with this <name> already exists" after adding lookup_field
I'm having to override .create() and .update() in my serializer due to having a nested relationship crmfields. I'm extending the User model and adding some fields in from our CRM system that sync over via Webhooks. Basically if a user is created/updated there, it syncs them over to the web application. My POST looks like the following: { "username": "test@test.com", "first_name": "Test First", "last_name": "Test Last", "email": "test@test.com", "is_active": true, "crmfields": { "guid": "00000000-0000-0000-0000-000000000001" } } This creates the user and corresponding crmfields record at roughly the same time. The issue I'm running into is with PUT and doing something like the following: { "username": "test@test3.com", "first_name": "Test First1", "last_name": "Test Last2", "email": "test@test1.com", "is_active": true, "crmfields": { "guid": "00000000-0000-0000-0000-000000000001" } } This returns a response of: { "crmfields": { "guid": [ "crm fields with this guid already exists." ] } } It doesn't look like it gets to my custom .update() method in the serializer before this error triggered. I had this working several months ago. Since then I've added lookup_field to the views.py because we decided we wanted to use the guid in the crmfields as the lookup (e.g. /api/users/00000000-0000-0000-0000-000000000001/)and not the pk in the Users model. There … -
Static CSS files not updating/loading in Django project
Problem: None of the changes I'm making to my CSS files are being applied to my HTML pages. So I tried to clear the cache and now my site says it can't find my static files. Exact error when I inspect my page in developer mode "GET http://127.0.0.1:8000/static/css/style.css%3F net::ERR_ABORTED 404 (Not Found)" Background: I'm creating a basic image editing site using django, html/css, and injecting JS to apply some filters to images. Previously I was able to make changes and they were reflected, but now whenver I try and make any html/css files none of the css gets linked nor are changes being applied. Things I've tried: Gone into settings cleared browser cache Disabled caching in developer mode appended the version of css file ?v1.1 to force a rest (caused the 404 error from above) Run collectstatic in terminal Cleared cache opened site in private window Watched several youtube vids on setting up static file dir and I think its correct. At some point in time my css was loading and updating as I made changes. Directory Layout These are my settings Settings.py BASE_DIR = Path(__file__).resolve().parent.parent DEBUG = True INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'Image_API', 'rest_framework', … -
How to delete an object using javascript in django
I want to do the delete operation by javascript with a confirmation window. How to do it? <div class="card-footer"> <a href="{% url 'course_delete' student.slug %}"><button>Delete</button></a> </div>