Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Url or Path inside urlpatterns in django
I am new to Django Api. While writing urls inside the app api url file, sometimes people use path and sometimes they use url in urlpatterns as shown below. And when they use path instead of url, they use routers just like below. I am totally cofused as to which one to use when?Plese help. This is path version. router = routers.DefaultRouter() router.register(r'user', views.UserCreateAPIView) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. urlpatterns = [ path('', include(router.urls)), path('register', include('rest_framework.urls', namespace='rest_framework'))] This is url version. urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^products/$', views.product_list), url(r'^products/(?P<pk>[0-9]+)$', views.product_detail), ] -
Enviroment variables in pyenv-virtualenv
I have created a virtual environment with pyenv virtualenv 3.5.9 projectname for developing a django project. How can I set environment variables for my code to use? I tried to add the environment variable DATABASE_USER in /Users/developer/.pyenv/versions/projectname/bin/activate like this: export DATABASE_USER="dbuser" When I tried to echo $DATABASE_USER an empty string gets printed. Tried to install zsh-autoenv And now I can echo $DATABASE_USER and get the value set in the .autoenv.zsh file. But I can't seem to get the environment variable to be available to my django code: def getenv(key, default, prefix=''): try: return os.environ[prefix + key] except KeyError: if default is not None: return default else: raise ImproperlyConfigured('The {}{} environment variable must be set'.format(prefix, key)) If I try to getenv('DATABASE_USER', '') in the python shell inside the virtualenv, I get '' What could be wrong? Is the zsh-autoenv variables just available for the zsh shell and not python manage.py shell ? -
Redirect to previous url (update form filled in half)
In my app user is filling the form to update item. The are dropdown lists to choose from (foreign key relations) It there is no requested item on the list user can add his own item. He can do this using a separate modal form. (adding new item) After adding this new item I would like to redirect the user back to initial updating. I was trying to use hidden input: next = request.POST.get('next', '/') return HttpResponseRedirect(next) and return HttpResponseRedirect(request.META.get('HTTP_REFERER')) but I failed. My idea was to redirect the user to the previous URL: [![PREVIOUS URL][1]][1] views.py class NewSalesPersonDistributor(BSModalCreateView): template_name = 'newsalespersondistributor.html' form_class = NewSalesPersonDistributor success_url = "/VCI" def get_success_url(request): next = request.POST.get('next', '/') return HttpResponseRedirect(next) class VCIUpdateView(UpdateView): model = VCI context_object_name = 'VCIUpdate' form_class = VCIModelForm template_name = 'VCIupdate.html' success_url = "/VCI" urls.py path('VCIUpdate/<pk>', VCIUpdateView.as_view(), name='VCIUpdate'), path('createsalesperson/', NewSalesPersonDistributor.as_view(), name='new_sales_person_distibutor'), html div class="container"> <div class="row py-4"> <div class="col"> <form method="post" id="subsidiaryForm" name="text" data-subsidiaries-url="{% url 'ajax_load_subsiriaies' %}" data-salesPersonsDistributor-url="{% url 'ajax_load_salesPersonsDistributor' %}" data-salesPersonsDistributorContact-url="{% url 'ajax_load_salesPersonsDistributorContact' %}" novalidate> <table class="table table-borderless table-condensed"> {% csrf_token %} {{ form.as_table }} </table> <input type="hidden" name="next" value="{{ request.path }}"> <input type="hidden" name="build" value="{{ VCIUpdate }}">, <input id="submit" type="submit" value="save" /> </form> </div> <div class="col" id="filia" data-filia-url="{% url … -
Made a app and want to access its models in other apps and want to restrict user registration for accessing website
I am working on a django project , I am a beginner and thought that i should make a new app for user management so made it but now want to access the models of that app from other apps and also want to ensure that before accessing evry url of website the user has to login i have used UserCreatonForm and extended it. -
How to localize datetime in Django view code?
I have a datetime in "models.py": class Foo(models.Model): modified = models.DateTimeField() When I display this in a template it comes out correct i.e. according to my locale settings (I'm in British Summer Time): {{ foo.modified }} Settings: LANGUAGE_CODE = 'en-gb' TIME_ZONE = 'Europe/London' USE_I18N = True USE_L10N = True USE_TZ = True Correctly outputs what I'd expect "7 Sep 2020, 2:43 p.m." (printing "modified" in the view gives "2020-09-07 13:43:40.988953+00:00"). However when I try to copy this formatting to a string in the view I get the wrong date / time (it has not adjusted by one hour): from django.utils.formats import localize from app.models import Foo foo = get_object_or_404(Foo, pk=1) modified = localize(foo.modified, use_l10n=True) print(foo.modified) Outputs "7 Sep 2020, 1:43 p.m.", which is wrong. I tried the other answers on this thread and none outputted the adjusted datetime: Stack Overflow thread -
How to get the time to read a blog in Django?
In blogs, news articles, etc., there are these text that says x min read. I want to know how this is done. I know this seems very simple but I've tried searching for this on the internet unfortunately, I can't seem to find it. I've seen this somewhere before but I forgot the proper term for this. Can anyone help me out? Can anyone suggest a tutorial website/documentation/video for this? Thank you. -
Keycloak user Invitation email
I am using Keycloak-9.0.2 as SSO in my Django project. I want to get send an invitation link in the e-mail by one user to another user. Is there any inbuilt functionality in Keycloak for the same? If not then what should be the better way to do this in Django. -
How to implement markdown2 in the template tags? Getting TemplateSyntaxError 'md2' is not a registered tag library
I followed instructions at this source for getting markdown2 to work in the template tags. The code is below. settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'wikiencyc', 'markdown2', ] entry_detail.html {% load md2 %} <h4>{{ entry.subject }} </h4> <br><br> <p> {{ entry.content|markdown:"safe" }} </p> So, I have done everything according to book. I also made sure that markdown2.py is in the path. But I get the following error. TemplateSyntaxError at /wikiencyc/entry/9 'md2' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz What am I doing wrong? -
Django order by issue when used Q filter with multiple order by and distinct
I am working on a photos project where a user can Download or Like a photo (do other operations as well) . I have two models to track this information. Below are the models used (Postgres the database used). # Photo model stores photos # download_count, like_count is stored in the same model as well for easier querying class Photo(models.Model): name = models.CharField(max_length=100, null=True, blank=True) image = models.ForeignKey(Image, null=True, on_delete=models.CASCADE) download_count = models.IntegerField(default=0) like_count = models.IntegerField(default=0) views = GenericRelation( 'Stat', related_name='photo_view', related_query_name='photo_view', null=True, blank=True) downloads = GenericRelation( 'Stat', related_name='photo_download', related_query_name='photo_download', null=True, blank=True) # Stat has generic relationship with photos. So that it can store any stats information class Stat(models.Model): VIEW = 'V' DOWNLOAD = 'D' LIKE = 'L' STAT_TYPE = ( (VIEW, 'View'), (DOWNLOAD, 'Download'), (LIKE, 'Like'), ) user = models.ForeignKey( User, null=True, blank=True, on_delete=models.SET_NULL) content_type = models.ForeignKey( ContentType, on_delete=models.CASCADE, default=0) object_id = models.PositiveIntegerField() content_object = GenericForeignKey() stat_type = models.CharField(max_length=2, choices=STAT_TYPE, default=VIEW) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) My requirement is fetch the Photos that are popular this week. The popularity score should consider the likes count, download count. I had written below query to get the popular photos this week which checks the likes or downloads created this week. … -
Import code works fine on local computer but gives error on aws
models.py from django.conf import settings from django.db import models from subject.models import Subject from core.utils import generate_file_name def file_upload_path(instance, filename): # File will be uploaded to MEDIA_ROOT / user_<id>/<filename> name = instance.slug + ".zip" file_path = generate_file_name() return 'project_{0}/{1}/{2}'.format(file_path, instance.slug, name) def image_upload_path(instance, filename): # File will be uploaded to MEDIA_ROOT / user_<id>/<filename> if instance.project_image1 == filename: filename = "image_1.png" elif instance.project_image2 == filename: filename = "image_2.png" elif instance.project_image3 == filename: filename = "image_3.png" return 'project_{0}/{1}'.format(instance.slug, filename) class Project(models.Model): """This is model for project""" project_name = models.CharField(max_length=50,) description = models.TextField() slug = models.SlugField() technologies = models.TextField() owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) price = models.DecimalField(max_digits=99, decimal_places=2) subject = models.ManyToManyField( Subject, related_name="projects") created = models.DateField(auto_now_add=True) project_image1 = models.ImageField(upload_to=image_upload_path) project_image2 = models.ImageField( blank=True, null=True, upload_to=image_upload_path) project_image3 = models.ImageField( blank=True, null=True, upload_to=image_upload_path) project_zip = models.FileField(upload_to=file_upload_path) def search_by_id(self, id): return self.objects.get(id=id) def search_by_slug(self, slug): return self.objects.get(slug=slug) views.py from rest_framework import viewsets, generics from rest_framework.parsers import FormParser, MultiPartParser, FileUploadParser from .models import Project from .serializers import ProjectSerializer, ProjectListSerializer from .permissions import IsOwnerOrReadOnly class ProjectCreateView(generics.CreateAPIView): parser_classes = (MultiPartParser, FormParser,) serializer_class = ProjectSerializer permission_classes = [IsOwnerOrReadOnly, ] def perform_create(self, serializer): serializer.save(owner=self.request.user) class ProjectListView(generics.ListAPIView): parser_classes = (FileUploadParser,) serializer_class = ProjectListSerializer queryset = Project.objects.all() class ProjectRetrieveView(generics.RetrieveAPIView): parser_classes = (FileUploadParser,) serializer_class = … -
Django admin StackedInline won't work in production
I'm having problems understanding why same code would work well locally but it won't work as expected when it's hosted on server. I use three OneToOneField connected to a model as following: class Order(models.Model): customer = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True, blank=True) order_date = models.DateTimeField(default=timezone.now, verbose_name='Data comenzii') ... class OrderItem(models.Model): order = models.ForeignKey(Order, on_delete=models.CASCADE, null=False, blank=False) product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='Produs') ... class InvoiceInfo(models.Model): CUSTOMER_TYPE_CHOICES = [ ('PF', 'Persoană fizică'), ('PJ', 'Persoană juridică'), ] order = models.OneToOneField(Order, on_delete=models.CASCADE, primary_key=True) customer_type = models.CharField(max_length=100, choices=CUSTOMER_TYPE_CHOICES, default='PF', verbose_name='Tip client') # Pers. fizica customer_firstname = models.CharField(max_length=100, blank=True, null=True, verbose_name='Prenume') customer_lastname = models.CharField(max_length=100, blank=True, null=True, verbose_name='Nume') class DeliveryInfo(models.Model): order = models.OneToOneField(Order, on_delete=models.CASCADE, primary_key=True) # contact person customer_firstname = models.CharField(max_length=100, blank=False, null=False, verbose_name='Prenume') customer_lastname = models.CharField(max_length=100, blank=False, null=False, verbose_name='Nume') Using admin manager as following: from .models import Order, OrderItem, InvoiceInfo, DeliveryInfo, PaymentMethodInfo class InvoiceInfoInline(admin.StackedInline): model = InvoiceInfo class DeliveryInfoInline(admin.StackedInline): model = DeliveryInfo class PaymentInfoInline(admin.StackedInline): model = PaymentMethodInfo class OrderItemInline(admin.StackedInline): model = OrderItem extra = 0 readonly_fields = ('product_link',) class OrderAdmin(admin.ModelAdmin): inlines = [ InvoiceInfoInline, DeliveryInfoInline, PaymentInfoInline, OrderItemInline, ] And locally it works fine and all fields are displayed properly. But in production the only field that is diplayed properly is OrderItemInline and other three are missing. … -
tag_model uninitialized in migrations
I have written Migration file for Django taggit to convert all the tags in lowercase into database but If I am trying to add new tag then I am getting the following error: AttributeError: type object 'InventoryProductTag' has no attribute 'tag_model' Code for tag in tags: if any(tag.isupper() for tag in tag.name): tag.name = tag.name.lower().strip() try: with transaction.atomic(): tag.save() except IntegrityError as ex: if (ex.__cause__.diag.constraint_name == "taggit_tag_name_key"): products = InventoryProduct.objects.filter(tags=tag) if products: for product in products: product.tags.add(tag.name) product.save() -
Why variables declared in settings.py are not visible in models.py if declared outside model class?
I have the following code in models.py from django.conf import settings from django.db import models SOME_VAR_FROM_SETTINGS = settings.FAS_BR_ROOT_SITE class FasSolution(models.Model): solution_id = models.CharField(max_length=64) doc_date = models.DateTimeField() title = models.TextField() @property def document_1_url(self) -> str: return self.title + SOME_VAR_FROM_SETTINGS For some reason, if SOME_VAR_FROM_SETTINGS is declared as it is in my code (i.e. at the the very begining of the models.py, not inside FasSolution class) - it becomes equal to None inside document_1_url property. However, in the reality its value is not None but some text string. What is interesing is that If I move SOME_VAR_FROM_SETTINGS declaration inside FasSolution class, then its value from settings.py becomes reachable (i.e. it becomes actual text string instead of None). Why does it happen? In other words, why variable declaration outside my model class makes it unreachable? -
I can't delete products
I've been coding in the framework django for two weeks and now I am learning to delete products. Here's the html code I've done: {% extends 'base.html' %} {% block content %} <form action = '.' method= 'POST'> {% csrf_token %} <h1>Do you want to delete the product "{{ object.title }}"?</h1> <p><input type= 'submit' value = 'Yes' /> <a href='../'>Cancel</a></p> </form> {% endblock %} And the function I've coded to delete the product def product_delete_view(request, my_id): obj = get_object_or_404(Product, id = my_id) if request.method == "POST": obj.delete() context = { 'object': obj } return render(request,"products/product_delete.html", context) Here's my url path: path('products/<int:my_id>/delete', product_delete_view, name= 'product-delete') However, my product doesn't get deleted. -
Django un Azure Webapp: Run command on deployment
I am deploying a Django app to Azure Webapp, which does everything automatically. I have set it up so when I push to a specific Github branch, it is deployed and everything works. If I have to run a migration, I must login via SSH and run it manually (which is not perfect but I can accept it). However, I need to use django-background-tasks, which needs to have a command running constantly listen for new tasks. I can't find a way to run this on every deployment. I found some documentation but most of it is for Node apps, it seems. For example, following some (oudated) tutoriales, I logged into {myapp}.scm.azurewebsites.net but I didnt find any "Download deployment scripts", which it seemed to be the proper way to do it. Is there a way to set up some commands to run on deployment (without changing my current setup of deploy directly from Github using Github actions)? Or I have to do it manually? -
Django Query whether the field is an m2m field and display the data
I have a modelclass like: class A (models.Model): name = models.CharField (max_length = 250) Bs = models.ManyToManyField ('B') Cs = models.ManyToManyField ('C') and a Formclass like: class AForm (forms.ModelForm): class meta: model = A fields = ['name', 'Bs'] labels = {'name': 'name', 'Bs': 'list of B', 'Cs': 'list of C'} now i want to show this on a website. The problem for me is the M2M field, I would like it to be like: https://i.stack.imgur.com/3KSpq.png represent. Therefore I would now have to query in the html whether it is a ModelMultipleChoiceField field is about adapting the presentation for me: {% for field in AForm %} {% if field.field == django.forms.models.ModelMultipleChoiceField %} blah {% else %} {{field}} {% endif %} {% endfor %} Unfortunately, I already fail when asked whether the current field is an m2m field. How can I do that? In addition, the M2M field currently only shows the ids? on? it says: B (1) B (2) B (3) B (4) B (5) B has a first and last name, however, it would be nicer if there: Firstname1 Lastname1 Firstname2 Lastname2 Firstname3 Lastname3 Firstname4 Lastname4 Firstname5 Lastname5 -
Ajax load url with Django
I want to pass two variables to Django function throw ajax load. my code: $( '#emp_clk' ).click( function() { emp = $( '#emp' ).val(); emp_Id = emp.split('-')[1]; $( '#extable' ).html( '&nbsp;' ).load( "{% url 'training:add_emp_student' %}?emp_Id=" + emp_Id ); }); I want to pass another variable, like $( '#emp_clk' ).click( function() { emp = $( '#emp' ).val(); emp_Id = emp.split('-')[1]; emp_Name = emp.split('-')[0]; $( '#extable' ).html( '&nbsp;' ).load( "{% url 'training:add_emp_student' %}?emp_Id=" + emp_Id + emp_Name ); what should I do !? }); -
What is the standard and safe method to modify users model in Django?
I was following a tutorial for creating custom user models for a Django application. I followed a link to the Django documentation from the tutorial but was met with the following warning: This document is for an insecure version of Django that is no longer supported. Please upgrade to a newer release! So I have been led to the question of whether using AbstractBaseUser and AbstractUser insecure? I have tried looking for other ways to modify the default users model but have had no luck so far. -
Get all ManyToManyField objects from a related ForeignKey
Goal: List of projects and for each project all members of that project I've been struggling with this for a while now; I have three models, as shown below (simplified versions of them): class Project(models.Model): name = models.CharField(max_length=200) class Workstream(models.Model): name = models.CharField(max_length=200) members = models.ManyToManyField(User) project = models.ForeignKey(Project, on_delete=models.CASCADE) class User(AbstractBaseUser): email = models.EmailField( verbose_name='email address', max_length=255, unique=True, ) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) What I want: to show an overview of each project, including a list of people on the project. I was playing around a bit in the html template and came up with this (but this is not what I am looking for): {% for project in projects %} {{project.name}} <br> {% for workstream in project.workstream_set.all %} {{workstream.members.all}} {% endfor %} <br><br> {% endfor %} The problem with the above is that users can be in multiple workstreams and therefore show up multiple times if this is the case. A related question I have if is it is possible to get all users related to a project without having the addition for loop for workstream, I have only added this now because I did not find a way to do this directly. -
how to populate current user in django forms
i have 2 models Employee and Leave where employee is a foreign key in Leave.now when a employee is applying for a leave i want the employee name option to be limited to only the logged in user rather than all employees.can i create a custom input with read-only and send user data using {{}} ,im not able to retrieve data from input group to models here is my codes models.py class Employee(models.Model): user=models.OneToOneField(User,on_delete=models.CASCADE) no_of_leaves=models.IntegerField(null=False,validators=[MinValueValidator(1), MaxValueValidator(24)],default=24) def __str__(self): return self.user.username class Leave(models.Model): employee=models.ForeignKey(Employee,on_delete=models.CASCADE,default="") start_date=models.DateField(auto_now_add=False) end_date=models.DateField(auto_now_add=False) req_date=models.DateTimeField(default=datetime.datetime.now()) approved_by=models.CharField(max_length=100,blank=True) STATUS_OPTIONS=( ("Approved","Approved"), ("Pending","Pending"), ("Declined","Declined"), ) approved=models.CharField(max_length=10,choices=STATUS_OPTIONS,default='Pending') def __str__(self): return self.employee.user.username @property def date_diff(self): return (self.end_date - self.start_date).days forms.py class leaveForm(forms.ModelForm): class Meta(): model = Leave fields = ('employee','start_date','end_date') # start_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'})) widgets = { 'start_date': DateInput(attrs={'type': 'date'}), 'end_date': DateInput(attrs={'type': 'date'}) } views.py @login_required def applyforleave(request): user=request.user emp=Employee.objects.get(user=user) submitted= False if request.method == 'POST': leave_form = leaveForm(data=request.POST) emp_name=employee(data=request.POST) if leave_form.is_valid() and emp_name.is_valid(): emp_name.save() start_date= leave_form.cleaned_data.get("start_date") end_date= leave_form.cleaned_data.get("end_date") days=(end_date-start_date).days days_checker=emp.no_of_leaves-days if 0 < days_checker < emp.no_of_leaves: leave = leave_form.save() leave.set_employee leave.save() submitted = True else: print("error") else: print(leave_form.errors) else: leave_form = leaveForm() return render(request,'leaveApp/leave.html', {'leave_form':leave_form, 'submitted':submitted,'emp':emp}) leave.html <div class="container"> <div class="jumbotron"> <form enctype="multipart/form-data" method="POST"> {% csrf_token %} {{ leave_form.as_p }} <input type="submit" name="" … -
504 timeout on AWS with nginx and gunicorn
I am running a python Django app on an AWS EC2 instance. It uses gunicorn and nginx to serve the app, the EC2 is behind an application load balancer. Occasionally I get 504 error where the entire EC2 instance becomes unreachable for everyone (including via SSH which I use all the time otherwise). I then need to restart everything which takes time. I can replicate the error by overloading the app (e.g. uploading and processing a very large image), in that case, gunicorn worker times out (I see the timeout message in logs), 504 error appears and the instance becomes unreachable. I set my gunicorn to time out in 5 minutes (300 seconds) but it falls down quicker than that. There is nothing really useful in CloudWatch logs. I am looking for ways to resolve this for all current and future cases. I.e., I want to have the situation where, if the site gets overloaded, it returns an error message as opposed to becoming completely unreachable for everyone. Is there a way to do that? -
Diffrence in update and create method of viewset django
Whenever I try to post something it posts I dont know how django is posting stuffs . Got confused in update() and create() in viewset. . I dont have create() method in my code. HOw is post method working? http_method_names = ['get', 'put','post'] def get_queryset(): //some code def update(): //some code -
How do I fix this Django in azure deployment error “Exception Type: OperationalError Exception Value: no such table?"
I have this Django app running on my computer, as a local server and I deployed it to an azure server. It works fine locally however when it runs on the azure server gives me this error. Request Method: POST Request URL: http://runnify.azurewebsites.net/route/ Django Version: 3.0.5 Exception Type: OperationalError Exception Value: no such table: pages_routerequest Exception Location: /antenv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 396 Python Executable: /opt/python/3.7.7/bin/python3.7 Python Version: 3.7.7 Python Path: ['/opt/python/3.7.7/bin', '/home/site/wwwroot', '/antenv/lib/python3.7/site-packages', '/opt/python/3.7.7/lib/python37.zip', '/opt/python/3.7.7/lib/python3.7', '/opt/python/3.7.7/lib/python3.7/lib-dynload', '/opt/python/3.7.7/lib/python3.7/site-packages'] Server time: Mon, 7 Sep 2020 11:21:54 +0000 I can't understand what is wrong, since I am not using a pages_routerequest anywhere. in my models.py I have: from django.db import models from django.contrib.postgres.fields import JSONField class Coordinates(models.Model): """Model representing a route coordinate generated (e.g. Science Fiction, Non Fiction).""" coordinates = JSONField() def __str__(self): """String for representing the Coordinates objects""" return self.coordinates class RouteRequest(models.Model): running_distance = models.FloatField() user_location = models.CharField(max_length=8000) -
How to handle 'Cancel' - django allauth linkedin
I am using allauth Django pacakge for linkedin authentification. The login is working succesfully, the problem I have is when the user chooses to Cancel the authetification. Then user gets redirected to this URL: http://127.0.0.1:8000/accounts/linkedin_oauth2/login/callback/?error=user_cancelled_login&error_description=The+user+cancelled+LinkedIn+login&state=1BOK8XL2Xu3R Which generates the authentification error which it's normal, I believe: Social Network Login Failure An error occurred while attempting to login via your social network account. {'provider': 'linkedin_oauth2', 'code': 'unknown', 'exception': None} How can I treat/avoid this error in order to have a an errorless flow ? -
How do I make Javascript inside Django code listen & respond to on click events on the front end?
I have a page which has a list of products. For each product, I have a button (Add to Cart). Once a user clicks on this button the product gets added on a side panel (aka cart). This side panel has: Quantities to be changed Delete icon - in case user wants to remove the product from the cart. So, these delete icons are created run time every time a user adds the product to the cart. Now, I have an event listener in my JS which would listen to click on the delete icon and then remove the product. But, any clicks on the delete icons are not getting responded. Funny thing is if I take the same JS code and use it in Chrome console it works. Any idea why this is not working ?