0

template

<form method='POST' action="{% url 'delete' city_weather.id %}">

urls.py

path('delete/<int:city_id>/',views.delete,name='delete')

views.py

def delete(request,city_id):
    city = get_object_or_404(CityUser,pk=city_id)
    city.delete()
    return redirect('home')

please click the link to see the error page

here is the error page

what have i done wrong ? Please help me out

Thanks in advance

Milan Mangar
  • 41
  • 1
  • 9

1 Answers1

0

I would comment for clarity but I need 4 more reputation to do so. Nevertheless, I need the following to help you debug it.

  1. Is the urlpattern you show part of an include() from the project's root folder???
  2. Show us your CityUser model
  3. Did you ever create an instance of that model???

Without those no one can really tell, because your issue is that the url is not found (NoReverseMatch error). Off the top of my head, the most likely culprit could be an include() with an app_name that you didn't show, so you might not be referencing it correctly in the template. Or it might also be something with your model. All model objects have an id, and you are passing the argument in correctly, but maybe you never created an instance to begin with.

So show me those things and I'll help more.