Reputation:
and I do not know why and what will be the problem, could they help me? Thanks beforehand, greetings!
Reverse for 'entregado' with arguments '()' and keyword arguments '{'cod_experto': 'ASE-0048', 'id_pedido': 1770}' not found. 1 pattern(s) tried: ['solicitar/confirmar/(?P<id_pedido>\\d+)/(?P<cod_experto>\\d+)/$']
Error during template rendering admindata.html, error at line 74:
<td><a href="{% url "usuario:entregado" id_pedido=ped.id cod_experto=ped.articulo.cod_experto %}" method='GET' type="submit" class="btn btn-success pull-right" value="editar" onclick="document.location.reload();"/>Entregar</a></td>
url global:
urlpatterns = [
# Examples:
url(r'^solicitar/', include(urls, namespace="usuario")),
]
url APP:
urlpatterns = [
url(r'^confirmar/(?P<id_pedido>\d+)/(?P<cod_experto>\d+)/$', login_required(Update_stock), name='entregado'),
]
and views.py:
def Update_stock(request, id_pedido, cod_experto):
if request.method == 'GET':
pedido = Pedido.objects.get(id=id_pedido)
articulo = Articulo.objects.get(id=cod_experto)
articulo.stock -= pedido.cantidad
stock.save()
return render(request, 'admindata.html', {'pedido':pedido, 'articulo':articulo})
Upvotes: 1
Views: 52
Reputation: 599610
Your cod_experto
value is "ASE-0048", which does not match the regex \d+
- that only matches integers.
If you want to be able to accept values like that, you need to change your regex:
r'^confirmar/(?P<id_pedido>\d+)/(?P<cod_experto>[\w-]+)/$',
Upvotes: 2