vendredi 5 avril 2019

int() argument must be a string when trying to do a form in django

i have a problem. I am trying to do a edit form with django. But when i go to the url to edit for example: /adminview/edit/1/

i got the message:

TypeError at /adminview/edit/1/
int() argument must be a string, a bytes-like object or a number, not 
'builtin_function_or_method'
Request Method: GET
Request URL:    http://127.0.0.1:8000/adminview/edit/1/
Django Version: 2.1.5
Exception Type: TypeError

this is my urls.py:

app_name = 'adminview'

urlpatterns = [
url(r'^$', index_admin, name="adminview"),
url(r'^clasification', clasification, name="clasification"),
url(r'^edit/(?P<id_category>\d+)/$', edit_clasificacion, name="edit_clasificacion"),
]

and this is a part from my views.py where i have the function that i am trying to built:

 def edit_clasificacion(request, id_category):
   clasificacion = Clasificacion.objects.get(id=id)
   if request.method == 'GET':
       form = ClasificacionForm(instance=clasificacion)
   else:
       form = ClasificacionForm(request.POST, instance=clasificacion)
       if form.is_valid():
           form.save()
       return redirect('article:index')
   return render(request, 'adminview/clasification.html', {'form':form})

any help? thanks a lot!




Aucun commentaire:

Enregistrer un commentaire