My project is to build a supermarket website.customers can input the quantity of the products so that I can calculate price.I use the first product 'apple' to test for whether I can get the typing integer by the customers and show on the price.html. My expected result is '1'I have tried many times but it still show none.Can anyone help me? my views code is like this:
def price(request):
a = request.GET.get('apple')
return render(request, 'price.html', {'a': a})
meat-series html file is like:
{% block content %}
<body>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
{% for ser in meat_ser %}
<div style="position:sticky ;" class= "row" >
<div class="col-sm-6">
<div class="card mb-3 " style="width: 18rem;">
<img style="height: 250px;margin: 0%;" id='photo'src="{{ser.photo}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{ser.Name}}</h5>
<p class="card-text"></p>
<form action="price/" >
<label form='price/'>Qualitiy:</label>
<input type="number" name={{ser.Name}}>
<input type="submit" value="Buy">
</form>
The urls file is like this:
from django.urls import path, re_path
from . import views
app_name = 'web'
urlpatterns = [
path('', views.index, name='index'),
re_path(r'^login/', views.login_request, name='login'),
re_path(r'^register/', views.register_request, name='register'),
re_path(r'^meat_series/', views.meat_series, name='meat_series'),
path('logout/', views.logout_request, name='logout'),
path('price/', views.price, name='price')
]
The url showed when submitted is: http://127.0.0.1:8000/web/meat_series/price/?apple=1