help with this error:
Reverse for 'pedido_sub' with arguments '()' and keyword arguments '{'cod_experto': 'AA-0002', 'id_pedido': 53}' not found. 1 pattern(s) tried: ['solicitar/aprobar/(?P<id_pedido>\d+)/(?P<cod_experto>\d+)$']
- Mark me in red the index.html tag:
< a href="{% url "usuario:pedido_sub" id_pedido=ped.id cod_experto=ped.articulo.cod_experto %}"
type="submit"
- The code for this button is found in views.py:
def pedido_sub(request, id_pedido, cod_experto):
art = Articulo.objects.get(id=cod_experto)
pedido = Pedido.objects.get(id=id_pedido)
if request.method == 'GET':
pedido.estado = 'entregado'
pedido.save()
pedido.fecha_entrega = datetime.now()
pedido.save()
art.stock = pedido.cantidad - art.stock
art.save()
return redirect('usuario:home')
return render(request, 'index.html', {'pedido':pedido}, {'art':art})
What the def does, is to extract the id of the order and also the one of the article ( cod_experto
), button that modifies two fields, this does it without problems, but when incorporating the subtraction of the quantity field of Order table and stock table Article, this error occurs and I have not been able to correct it, if you can help me and advise me I would appreciate it very much.