Я не знаю, что не так с моей настройкой Мои URL .py
from django.urls import path
from . import views
app_name = 'shop'
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('shop/Create_Product/', views.Create_Product, name='Create_Product'),
path('shop/product/Edit_Product/', views.Edit_Product, name='Edit_Product'),
]
Forms.py
from django import forms
from django.contrib.auth.models import User
from .models import Product
class CreateProduct(forms.ModelForm):
class Meta:
model = Product
fields = ["category", "name", "image", "description",
"price", "available", 'slug']
prepopulated_fields = {'slug': ('name',)}
class EditProduct(forms.ModelForm):
class Meta:
model = Product
fields = ["category", "name", "image", "description",
"price", "available"]
prepopulated_fields = {'slug': ('name',)}
Models.py
class Product(models.Model):
category = models.ForeignKey(Category,
related_name='products',
on_delete=models.CASCADE)
name = models.CharField(max_length=200, db_index=True)
slug = models.SlugField(max_length=200, db_index=True)
image = models.ImageField(upload_to='products/%Y/%m/%d',
blank=True)
description = models.TextField(blank=True)
price = models.DecimalField(max_digits=10, decimal_places=2)
available = models.BooleanField(default=True)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Meta:
ordering = ('name',)
index_together = (('id', 'slug'),)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('shop:product_detail', args=[self.id, self.slug])
Views.py
@staff_member_required
def Edit_Product(request, id=None):
instance = get_object_or_404(Product, id=id)
if request.method == "POST":
form = EditProduct(request.POST, instance=instance)
if form.is_valid():
product = form.save(commit=False)
product.save()
return redirect('shop/product/detail.html')
else:
form = EditProduct(instance=instance)
return render(request,'shop/product/Edit_Product.html', {'form': form, 'product': instance})
Пожалуйста, кто-нибудь может помочь с этим, я настоящий нуб в django, и я посмотрел в inte rnet нет ответов Я пытался изменить шаблоны URL, но также не надеюсь и иногда это показывает отсутствие ключевого аргумента позиции, а иногда ошибка 404