[Answered ]-How can i solve Reverse for 'Add' with arguments '('',)' not found. 1 pattern(s) tried: ['agregar/(?P<producto_id>[0-9]+)/\\Z'] error?

1๐Ÿ‘

โœ…

ok guys i just fin the error to my problem, i going to post here for other people with the same problem.

In my serializer i dont specified the โ€˜idโ€™

class ProductoSerializer(serializers.HyperlinkedModelSerializer) :
class Meta:
    model = Producto
    fields = ['url', 'nombre', 'codigo', 'precio', 'serie_producto', 'marca']

soo, the solution is:

class ProductoSerializer(serializers.HyperlinkedModelSerializer) :
class Meta:
    model = Producto
    fields = ['id' #here ,'url', 'nombre', 'codigo', 'precio', 'serie_producto', 'marca']
๐Ÿ‘คWuaFlees

0๐Ÿ‘

django.urls.exceptions.NoReverseMatch: Reverse for 'Add' with arguments '('',)' not found. 1 pattern(s) tried: ['agregar/(?P<producto_id>[0-9]+)/\\Z']

This error tells you that the view with name 'Add' expects an integer argument, but you passed it an empty string ''. To debug this, you can add print(datos) before your render() call. Most likely you will see a list of JSON objects with at least one that has id: "".

๐Ÿ‘คCode-Apprentice

Leave a comment