【发布时间】:2022-02-14 00:29:25
【问题描述】:
这是我的 forms.py :
class stockupdateform(forms.ModelForm):
class Meta:
model:stock
fields =['categorie', 'nom', 'quantite']
我的意见.py:
def list_nom(request):
title='liste des produits'
form =stockSearchForm(request.POST or None)
queryset=stock.objects.all()
context= {
"title":title,
"queryset":queryset,
"form":form,
}
if request.method == 'POST':
queryset = stock.objects.filter(categorie=form['categorie'].value(),
nom=form['nom'].value())
context= {
"title":title,
"queryset":queryset,
"form":form,
}
return render(request, "list_nom.html",context)
我的 list_nom.html :
<table class='table'>
<thead>
<tr>
<th>id</th>
<th>categorie</th>
<th>produit</th>
<th>quantite</th>
</tr>
</thead>
{% for instance in queryset %}
<tr>
<td>{{forloop.counter}}</td>
<td>{{instance.categorie}}</td>
<td><a href="{% url 'modifier_produit' instance.id %}">{{instance.nom}} </a> </td>
<td>{{instance.quantite}}</td>
</tr>
{% endfor %}
</table>
我有这个问题我能做什么: /modifier_produit/1 处的 ValueError ModelForm 没有指定模型类。
【问题讨论】: