No Category matches the given query
I am trying to update my products so users can create product and use the checkout to fill form for payment, but when i click on the checkout button i am getting this No Category matches the given query.
Here is my code for the Order_create views
def order_create(request):
cart = Cart(request)
if request.method == 'POST':
form = OrderCreateForm(request.POST)
if form.is_valid():
order = form.save()
for item in cart:
OrderItem.objects.create(order=order, product=item['product'], price=item['price'], quantity=item['quantity'])
# clear the cart
cart.clear()
return render(request, 'products/products/created.html',{'order': order})
else:
form = OrderCreateForm()
return render(request, 'products/create.html')
and here is the URLS for my projects
urlpatterns = [
path('product/', include('products.urls', namespace='products')),
]
and here is the Order URLS
from django.urls import path
from . import views
app_name = 'products'
urlpatterns = [
path('', views.product_list, name='product_list'),
path('<slug:category_slug>/', views.product_list, name='product_list_by_category'),
path('<int:id>/<slug:slug>/', views.product_detail, name='product_detail'),
path('create/', views.order_create, name='order_create'),
]
When i clcick checkout, i got this error.... Page not found (404) No Category matches the given query. Request Method: GET Request URL: http://127.0.0.1:8000/product/create/ Raised by: products.views.product_list