Hi @KenWhitesell ! Thanks again for your help
Got it !
But I’m working on this “edit” view and just get :
Exception Type: ValueError
Exception Value:
The ProductModel could not be changed because the data didn't validate.
views.py
def edit(request, product_id):
product = ProductModel.objects.get(id=product_id)
if(request.method == "POST"):
form = ProductForm(request.POST, instance=product)
if(form.is_valid):
form.save()
return redirect("/")
else:
form = ProductForm()
template_name = "products/edit.html"
context = {
"ProductForm":ProductForm,
"ProductModel":ProductModel.objects.get(id=product_id),
}
return render(request,template_name,context)
edit.html
{% extends "base.html" %}
{% block page_title %}Products : {{ product.product_name }}{% endblock %}
{% block page_content %}
<form id="updateProductForm" action="" method="POST">
{% csrf_token %}
<label type="text" >Product Name : </label>
{{ ProductForm.product_name }}
<br>
<label type="text" >Product Description : </label>
{{ ProductForm.product_description }}
<br>
<input type="submit" value="Update">
</form>
{% endblock %}
Thank you in advance