Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Did you install mysqlclient? Django
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? -
Unable to serve django static files via nginx and docker
I am having issue with configuring a nginx server using docker and django. Here is my directory structure -nginx --default.conf --Dockerfile -portfolio_app (django webpapp) --main_app ---settings.py ---wsgi.py --sub_app ---views.py ---static ---media -docker-compose.yml -Dockerfile (django related) -entrypoint.sh (to start django server) Regarding django it working, but i am unable to serve the static files. I think i am not giving the path correctly. Here is Dockerfile related to django FROM python:3.8.13-slim-buster WORKDIR /app RUN pip install --upgrade pip COPY ./requirements.txt ./ RUN pip install -r requirements.txt COPY ./portfolio_app ./ COPY ./entrypoint.sh ./ ENTRYPOINT ["sh","/app/entrypoint.sh"] nginx files default.conf upstream django{ server portfolio_app:8000; } server { listen 80; location /{ proxy_pass http://django; } location /static/ { alias sub_app/static/; } } Dockerfile FROM nginx:1.19.0-alpine COPY ./default.conf /etc/nginx/conf.d/default.conf Here is docker-compose.yml file version: '3.3' services: portfolio_app: build: . container_name: portfolio_app volumes: - static_volume:/sub_app/static - media_volume:/sub_app/media ports: - "8000:8000" env_file: - .env nginx: build: ./nginx volumes: - static_volume:/sub_app/static - media_volume:/sub_app/media ports: - "80:80" depends_on: - portfolio_app volumes: media_volume: static_volume: I am not sure about the path of volumes in yml file and settings of default.conf. Here are the logs Successfully built 8459b7bb3baf Successfully tagged docker_nginx:latest Recreating b0f1b634454f_portfolio_app ... done Recreating docker_nginx_1 ... done Attaching to portfolio_app, … -
How to group by in a query for the Django admin serach?
I have a model called Task. The user shall search a specific search in the django admin area. So I implement the method: def get_search_results(self, request, queryset, search_term): in class TaskAdmin(admin.ModelAdmin): I define a queryset in a complicated way. But that works. I now have a wounderful queryset resulting in a nearly perfect SQL statement. There is just one thing missing. I would love to add a GROUP BY at the end. But how? I tried several things: The starting point: [...] queryset = self.model.objects.filter(joinedQ) Django aggregation: .values.aggregate() results normally in a group by, but I can't use .values for this query because django admin does not expect a dict as result. See: Group by day in django admin? using the hidden group_by attribute of the query: queryset.query.group_by = ["product"] queryset = QuerySet(query=queryset.query, model=Task) Does not work. The resulting query has all columns in group by, not only the product column like I specified. So it does not group anything. Query to string and than manually adding the GROUP BY string_query = str(queryset.query) string_query += 'GROUP BY "main_task"."product", "main_task"."version"' queryset = Task.objects.raw(string_query) This results in the correct query what will find the correct results, but I get an exeption: AttributeError: … -
how to insert data to database without forms.py in django
This method works fine for me can some one say how to add file or images like this def insert_students(request); name = request.POST['name'] class = request.POST['class'] student = studentsmodels(name=name, class=class) student.save() return redirect('/') return render(request, "insertpage.html") -
django get latest release QuerySet
class Release(models.Model): version = models.PositiveIntegerField(default=1) class Project(models.Model): project = models.ForeignKey('projects.Project', related_name='releases', on_delete=models.SET_NULL, blank=1, null=1) def getObjects(): releases = [] for project in Project.objects.all(): if project.releases.all(): releases.append(project.releases.all().order_by('-version')[0]) return releases is it possible to get a queryset of latest releases of each project if it has release? sorry I literally have no idea how to write the queryset. -
Django : make a migration run last consistently
I have a migration 0042_db_views.py creating database views that currently depends on the last migration. I want this migration 42 to always be the last one without rewriting its dependencies every time a new migration file is generated, even if we add a new migration say 0043_my_migration.py. I have red the Django docs and a bunch of SO questions, but did not found any solution for it, there is a run_before option but not a run_after... Is there a proper and reliable way to do it ? Something that would make dependencies=* in 0042_db_views.py for example, or an option that I did not found ? My Django version is 4.0.5 # 0042_db_views.py class Migration(migrations.Migration): dependencies = [ ("networks", "0041_migration_41"), ] operations = [ CreateView( name="My_Name", fields=[ ( "id", models.AutoField( auto_created=True, primary_key=True, serialize=False, verbose_name="ID", ), ), ], options={ "abstract": False, }, ) # 8 other views are created, not detailing them here ] -
Prevent concurrent logins django rest framework jwt authentication
I am using djangorestframework-simplejwt==4.4.0 in my application for User Authentication. But by default it provides multiple logins for a single user i.e. I can generate n number of tokens. What I want is to prevent multiple logins from the same account. How do I do that? Models.py class Company(models.Model): region_coices = (('East', 'East'), ('West', 'West'), ('North', 'North'), ('South', 'South')) category = (('Automotive', 'Automotive'), ('F.M.C.G.', 'F.M.C.G.'), ('Pharmaceuticals', 'Pharmaceuticals'), ('Ecommerce', 'Ecommerce'), ('Others', 'Others')) type = models.ManyToManyField(CompanyTypes) name = models.CharField(max_length=500, default=0) email = models.EmailField(max_length=50, default=0) class User(AbstractUser): is_admin = models.BooleanField(default=False) company = models.ForeignKey(Company, on_delete=models.CASCADE, blank=True, null=True) @property def full_name(self): return self.first_name + " " + self.last_name class EmployeeTypes(models.Model): emp_choices = (('Pool Operator', 'Pool Operator'), ('Consignor', 'Consignor'), ('Consignee', 'Consignee')) emp_type = models.CharField(max_length=500, default='Pool Operator', choices=emp_choices) class Employee(models.Model): role_choices = (('CRUD', 'CRUD'), ('View', 'View')) user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) company = models.ForeignKey(Company, on_delete=models.CASCADE, related_name="company") name = models.CharField(max_length=500, default=0) Urls.py path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), -
Recommendations on setting up models for Django social media app
I'm working on a personal social media project. Every user has a profile. --Profile model-- from django.db import models from django.contrib.auth.models import User from PIL import Image class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) image = models.ImageField(default='default.jpg', upload_to='profile_pics') background_image = models.ImageField(upload_to='profile_background_pics', blank=True, null=True,) bio = models.CharField(max_length=200, help_text="200 characters or less") In the profile, I want to have the option for the user to list all the tech stacks (programming languages and frameworks) that they work with and their level for each. Example pseudocode..: @testuser - Tech Stacks model - { Programming Languages: [Python (Intermediate), Java (Noob)], Frontend: [HTML (Intermediate), CSS (Intermediate), JS (Intermediate)], Frameworks: [Django (Getting there..)], Devops: [AWS (Noob), Heroku (Noob)], and so on... So each profile (since profile has OneToOne with contrib.auth.user) will have a tech stack model. The tech stack model will have multiple categories (languages, frameworks, etc). Each category has multiple objects. And each object will have user's level of proficiency. So if I query user.tech_stacks then it should return something like above. And user.tech_stacks.programming_languages should return [Python (Intermediate), Java (Noob)], I should also be able to query all the users that are Python (Intermediate) and Python (Advanced) Thanks for your help.. not really sure where to … -
How to call model method from serializer
I have method inside model: def has_midterm_contracts(self): """ Returns True if midterm contract has uploaded :rtype: boolean """ return MidtermContractFile.objects.filter( reservation_id=self.pk ).exclude( Q(attachment__isnull=True) | Q(attachment__exact='') ).exists() and how can I call it from serializer? I tried with needs_mid_term_contract_upload = serializers.SerializerMethodField() def get_needs_mid_term_contract_upload(self, record): if not record.has_midterm_contracts(): return False else: return True It gives me error AttributeError: 'dict' object has no attribute 'has_midterm_contracts' But, when I use if not record['has_midterm_contracts()']: it gives me other error KeyError: 'has_midterm_contracts()' Is there other way to try? -
WARNING:django.request:Not Found: /static/pygiustizia/js/common.js
I have set STATIC_ROOT and STATIC_URL in settings.py in my django webapp. settings.py import os STATIC_URL = 'static/' STATIC_ROOT = '/var/www/html/elastic_queries/python/djangosite/giustiziasite/pygiustizia/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "pygiustizia/static"), ) When I run one test I get these warnings messages Found 1 test(s). Creating test database for alias 'default'... System check identified no issues (0 silenced). nel costruttore model Users WARNING:django.request:Not Found: /static/pygiustizia/bootstrap-msg/examples/vendors/font-awesome-4.7.0/css/font-awesome.min.css WARNING:django.request:Not Found: /static/pygiustizia/bootstrap-msg/dist/css/bootstrap-msg.css WARNING:django.request:Not Found: /static/pygiustizia/js/common.js WARNING:django.request:Not Found: /static/pygiustizia/bootstrap-msg/dist/js/bootstrap-msg.js WARNING:django.request:Not Found: /static/pygiustizia/js/common.js If I insert url "/static/pygiustizia/js/common.js" with success I obtain common.js file displayed in browser. My test is made with selenium for python and web app is written with django framework. I don't understand how solve these warnings messages. -
How validate date in inlines in django admin?
How validate and work with cleaned data in inlines? my models: class ModelA(model.Model): name = models.CharField(max_length=20) class ModelB(model.Model): name = models.CharField(max_length=20) model_a = models.ForeignKey(ModelA, on_delete=models.CASCADE) my admin: @admin.register(ModelA) class ModelAAdmin(admin.ModelAdmin): inlines = [ModelBInLine,] class ModelBInLine(StackedInline): model = ModelB formset = ModelBForm can_delete = True class ModelBForm(BaseInlineFormSet): def __init__(self, *args, **kwargs): super(ModelBForm, self).__init__(*args, **kwargs) def clean(self): cleaned_data = super(ModelBForm, self).clean() #there cleaned_data is None for form in self.forms: form.instance.name = new_name #it's doesn't work return self.cleaned_data I need rewrite any fields in inlines model and make some validation logic. But, if I rewrite field, it's doesn't work. -
How to make my background image full screen?
I'm doing a project in python django and trying to make my background full screen. The html code: <div class="container-login100" style="background-image: url('{% static "webmonitor/images/bg-01.jpg" %}') ;" > The css code: .container-login100 { width: 100%; min-height: 100vh; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; padding: 15px; background-repeat: no-repeat; background-position: center; background-size: cover; height: 100%; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; } It currently looks like this: -
Django + Graphene + DjangoModelFormMutation : dissociating create and update
I am using a DjangoModelFormMutation from Graphene-python to expose a generic mutation for a model, like so : from graphene import Field from graphene_django.forms.mutation import DjangoModelFormMutation from django.db import models class Pet(models.Model): name = models.CharField() legs = models.PositiveIntegerField() class PetForm(forms.ModelForm): class Meta: model = Pet fields = ('name', 'legs') # This will get returned when the mutation completes successfully class PetType(DjangoObjectType): class Meta: model = Pet class PetMutation(DjangoModelFormMutation): pet = Field(PetType) class Meta: form_class = PetForm Then in my schema file, I register the mutation like this : create_pet = mutations.PetMutation.Field() update_pet = mutations.PetMutation.Field() This works, but there are two desired behaviors I can't achieve this way : Have two different mutations : one for create that can only create and not update, and one for update that can only update, and not create. Have the update mutation work partially as well , i.e only updating the client-provided fields. How can I achieve the desired behavior ? -
Transfer balance from one account to other using raw code
I am making a single page website where in a table username,balance are provided,and there is a from field that takes id and balance and transfer it to other accounts,but I am facing problems with transfering amount, heres my code, models.py, class Account(models.Model): username = models.CharField(max_length=30) balance = models.IntegerField() freeze_type = models.BooleanField(default=False) hold = models.BooleanField(default=False) def __str__(self): return self.username views.py, def transfer(request): transfer_id = int(request.GET.get('Account_id')) transfer_amount = int(request.Get.get('amount')) balance_1 = Account.objects.filter(id=id) balance_2 = Account.objects.filter(transfer_id) balance_1 = balance_1.balance - balance_2.balance balance_1.save() accounts = Account.objects.all() return render(request,'home.html',{'accounts':accounts}) and my froms code from html page, <form action="{% url 'transfer' %}"> <label for="Account_id">Account Id</label><br> <input type="text" id="Account_id" name="Account_id" ><br> <label for="Transaction_amount">Transaction Amount</label><br> <input type="text" id="Transaction_amount" name="amount" ><br> <input type="submit" class="button button4" value="Submit"> </form> I have also added a screenshot of my index page for better understanding,Home page when I run this code I got the error 'WSGIRequest' object has no attribute 'Get' so my question is that why is this error and is my views.py code is right? or to code for transferring balance -
My django project is missing a lot of defaults and installed packages are not working
When I make my django app there is typically a default sqlite3 that comes with it but for some reason it does not show up so I created a database in the MySQL workbench and then in my settings.py I made sure to add the relevant info. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'nameofDB', 'USER': 'root', 'PASSWORD': 'mypassword', 'HOST': 'localhost', 'PORT': '3306', } } In my virtual environment 'env' after activating it I made sure to install everything django, django-admin, pip. The name of my project is 'studybud' and the directory is: C:\Users\User\Desktop\studybud After making my project, I worked on it for a little and checked how the html was rendered so it was activted and I ran the server but after I left it alone for a while my powershell froze so i simply exited out of everything. Not sure if this affects my current problem. I tried opening my project again but now I get this error: in my virtual environment i did make sure to install mysqlclient before creating the mysql database but as you see its installed in a completely different directory which is the global one. although i would have thought the python … -
Can't connect django to exist MS SQL Server using mssql-django
I'm getting an error when trying to execute manage.py runserver. I've installed mssql-django and the odbc driver 17 for sql server. I am very new to django and python in general but I want to use exist ms sql server instead of sqlite. this my code in setting.py: DATABASES = { "default": { "ENGINE": "mssql", "NAME": "eHospital_DKAG_NSTL", "USER": "sa", "PASSWORD": "passwod", "HOST": "172.16.2.20\sqlservertest", "PORT": "1433", "OPTIONS": {"driver": "ODBC Driver 17 for SQL Server", }, }, } HERE IS ERROR MESSAGE: Exception in thread django-main-thread: Traceback (most recent call last): File "F:\Python\Django\fptdb\lib\site-packages\django\db\backends\base\base.py", line 244, in ensure_connection self.connect() File "F:\Python\Django\fptdb\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "F:\Python\Django\fptdb\lib\site-packages\django\db\backends\base\base.py", line 225, in connect self.connection = self.get_new_connection(conn_params) File "F:\Python\Django\fptdb\lib\site-packages\mssql\base.py", line 353, in get_new_connection conn = Database.connect(connstr, **args) pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: The wait operation timed out.\r\n (258) (SQLDriverConnect); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute (0); [08001] [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is … -
Not able to extend data into another page
I know I have asked this question before but I am really struggling with this despite having written the syntax correctly. I am making a shopping page and I am trying to extend the below table whose data is dynamically inserted, below is the table when I press on any of the categories(9-6 wear bridal wear etc), only the 'Our Product' is displayed on the extended page and the rest of the table doesnt come the part marked in red is missing below is the html code for 'shoppingpage.html' <h1>Hello, welcome to shopping page!</h1> <ul> <a class="lynessa-menu-item-title" title="Our Products" href="/allproducts">Our Products</a> <div class="submenu megamenu megamenu-shop"> <div class="row"> {% for result in category %} <div class="col-md-3"> <div class="lynessa-listitem style-01"> <div class="listitem-inner"> <a href="{% url 'polls:category' result.id %}" target="_self"> <h4 class="title">{{result.category_name}}</h4> </a> {% for ans in result.subcategories_set.all %} <ul class="listitem-list"> <li> <a href="{% url 'polls:subcategory' ans.id %}" target="_self">{{ans.sub_categories_name}}</a> </li> </ul> {% endfor %} </div> </div> </div> {% endfor %} </div> </div> </ul> {% block content %}{% endblock %} category.html {% extends 'polls/shoppingpage.html' %} <h1>Hello,to categorybase world!</h1> {% block content %} <ul class="row products columns-3" id="appendproducts"> {% for product in products %} <li class="product-item wow fadeInUp product-item rows-space-30 col-bg-4 col-xl-4 col-lg-6 col-md-6 col-sm-6 … -
error when updating a Django-based site page
gentlemen. I write like a novice programmer. I decided to make a website using Django and a problem arose: after edits in the code, these edits are not displayed on the site page. I tried to update many times, and also restarted the server. Nothing helps, if necessary, I can post the code, unfortunately I don't use the git -
Django AJAX SSO login
I have a cross domain post request from domainA to domainB. Both domain has SSO login enabled. If iam already logged in domainA how can i login in domainB using cros domain POST request to the domainB using AJAX. If I open the domainB in the browser it automatically log in the user. How to achieve this using AJAX request -
cx_Oracle Database error:ORA-00910:specified length too long for its dataype when using with django 4
Below is my code: from django.test import TestCase from myApp.models import myModel from myApp.serializers import myModel_serializer import requests import time class SendTestCase(TestCase): def __init__(self, *args, **kwargs): self.url = 'http://0.0.0.0:3000/a/b/' self.testData =[] super(SendTestCase, self).__init__(*args, **kwargs) def setUp(self): # pass print("setting up test case") modelInfo = myModel.objects.all() for info in modelInfo: info_serialized = myModel_serializer(info).data self.testData.append( { "Info" : info_serialized, } ) def tearDown(self): pass def test_send(self): print("sending") for data in self.testData: response = requests.post(self.url, data) self.assertEqual(response.status_code, 201) response.close() time.sleep(1) When I run python3 manage.py test myApp it informs that it is creating test database and test user. After that it gives me "django.db.utils.DatabaseError: ORA-00910: specified length too long for its datatype". Below is its traceback text: Creating test user... Traceback (most recent call last): File "/home/Documents/folder/FP_app/fp/lib/python3.10/site-packages/django/db/backends/utils.py", line 87, in _execute return self.cursor.execute(sql) File "/home/Documents/folder/FP_app/fp/lib/python3.10/site-packages/django/db/backends/oracle/base.py", line 552, in execute return self.cursor.execute(query, self._param_generator(params)) cx_Oracle.DatabaseError: ORA-00910: specified length too long for its datatype The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/Documents/folder/FP_app/API_AOS/manage.py", line 22, in <module> main() File "/home/Documents/folder/FP_app/API_AOS/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/Documents/folder/FP_app/fp/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/home/Documents/folder/FP_app/fp/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/Documents/folder/FP_app/fp/lib/python3.10/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv super().run_from_argv(argv) File … -
how to display all categories on template in django
I was trying to fetch all the categories on the template but they are repeating because there are multiple lines in database. here is what currently showing -
Nginx does not render favicon and statics files are not accessible. serving by Flask
I have a files in files and favicon.ico in static folder. Webpages is served by Nginx, favicon is not visible and files are not accessible. I tried reading some post but they fixing is not working on my. Here is configuration. The webpage is working but icon is not rendering. $ cat /etc/nginx/sites-enabled/my_app server { server_name www.mysite.com; location /static/ { # handle static files directly, without forwarding to the application alias /home/ubuntu/mysite/app/static/; expires 30d; } location = /_favicon.ico { alias /home/ubuntu/mysite/app/static/favicon.ico; } location / { # forward application requests to the gunicorn server proxy_pass http://localhost:8000; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/www.mysite.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/www.mysite.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = www.mysite.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name www.mysite.com; return 404; # managed by Certbot } thanks in advance -
NameError: Error fill report: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly[python]
I am using this https://pypi.org/project/pyreportjasper/ project to generate the jrxml to PDF while running the program I'm getting error like above. JDK already installed in my machine. File "d:\rigelsoft\curd_fastapi\jasper_t\pyjas.py", line 30, in <module> advanced_example_using_database() File "d:\rigelsoft\curd_fastapi\jasper_t\pyjas.py", line 28, in advanced_example_using_database pyreportjasper.process_report() File "D:\rigelsoft\curd_fastapi\fastenv\lib\site-packages\pyreportjasper\pyreportjasper.py", line 182, in process_report raise error NameError: Error fill report: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.``` MYcode: ```import os from platform import python_version from pyreportjasper import PyReportJasper def advanced_example_using_database(): REPORTS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'reports') input_file = 'jasper_t/testjp.jrxml' output_file = 'D:\\rigelsoft\\curd_fastapi\\jasper_t' print(input_file) conn = { 'driver': 'mysql', 'username': 'root', 'password': 'admin', 'host': 'localhost', 'database': 'curd', 'port': '3306', 'jdbc_dir': 'D:/rigelsoft/curd_fastapi/fastenv/Lib/site-packages/pyreportjasper/libs/jdbc/mysql-connector-java-8.0.21.jar',} pyreportjasper = PyReportJasper() pyreportjasper.config( input_file, output_file, db_connection=conn, output_formats=["pdf"], parameters={'python_version': python_version()}, locale='en_US' ) pyreportjasper.process_report() advanced_example_using_database()``` -
Not able to extend the categories subcategories table properly
I am making a shopping website and dynamically displaying data using serializers and foreign keys, and I am trying to extend the category subcategory table into another page. Below is the image of the table. Below is 'shoppingpage.html' The issue is that only 'Our Products' is getting extended but the rest of the table isnt getting extended as shown below Below is the html code for shoppingpage.html <ul> <a class="lynessa-menu-item-title" title="Our Products" href="/allproducts">Our Products</a> <div class="submenu megamenu megamenu-shop"> <div class="row"> {% for result in category %} <div class="col-md-3"> <div class="lynessa-listitem style-01"> <div class="listitem-inner"> <a href="{% url 'polls:category' result.id %}" target="_self"> <h4 class="title">{{result.category_name}}</h4> </a> {% for ans in result.subcategories_set.all %} <ul class="listitem-list"> <li> <a href="{% url 'polls:subcategory' ans.id %}" target="_self">{{ans.sub_categories_name}}</a> </li> </ul> {% endfor %} </div> </div> </div> {% endfor %} </div> </div> </ul> {% block content %} {% endblock %} category.html {% extends 'polls/shoppingpage.html' %} <h1>Hello,to categorybase world!</h1> {% block content %} <ul class="row products columns-3" id="appendproducts"> {% for product in products %} <li class="product-item wow fadeInUp product-item rows-space-30 col-bg-4 col-xl-4 col-lg-6 col-md-6 col-sm-6 col-ts-6 style-01 post-24 product type-product status-publish has-post-thumbnail product_cat-chair product_cat-table product_cat-new-arrivals product_tag-light product_tag-hat product_tag-sock first instock featured shipping-taxable purchasable product-type-variable has-default-attributes" data-wow-duration="1s" data-wow-delay="0ms" data-wow="fadeInUp"> <div class="product-inner tooltip-left"> … -
I`ve problem with js inner html,I`m trying to get data adn save it to base, but I don`t know how to fix it
` template: '<%var items = cart.items();var settings = cart.settings();var hasItems = !!items.length;var priceFormat = { format: true, currency: cart.settings("currency_code") };var totalFormat = { format: true, showCode: true };%> sbmincart-empty" action="" target=""> × <% for (var i= 0, idx = i + 1, len = items.length; i < len; i++, idx++) { %> <a class="sbmincart-name" href="<%= items[i].get("href") %>"><%= items[i].get("w3ls_item") %> <% if (items[i].get("item_number")) { %> <%= items[i].get("item_number") %> <input type="hidden" name="item_number_<%= idx %>" value="<%= items[i].get("item_number") %>" /> <% } %> <% if (items[i].discount()) { %> <%= config.strings.discount %> <%= items[i].discount(priceFormat) %> " value="" /> <% } %> <% for (var options = items[i].options(), j = 0, len2 = options.length; j < len2; j++) { %> <%= options[j].key %>: <%= options[j].value %> _" value="" /> _" value="" /> <% } %> <input class="sbmincart-quantity" data-sbmincart-idx="<%= i %>" name="quantity_<%= idx %>" type="text" pattern="[0-9]*" value="<%= items[i].get("quantity") %>" autocomplete="off" /> ">× <%= items[i].total(priceFormat) %> <input type="hidden" name="w3ls_item_<%= idx %>" value="<%= items[i].get("w3ls_item") %>" /> " value="" /> <input type="hidden" name="shipping_<%= idx %>" value="<%= items[i].get("shipping") %>" /> <input type="hidden" name="shipping2_<%= idx %>" value="<%= items[i].get("shipping2") %>" /> <% } %> <% if (hasItems) { %> <%= config.strings.subtotal %> <%= cart.total(totalFormat) %> "> <%- config.strings.button %> <% } else { …