Friday, April 28, 2017

Re: NoReverseMatch

hi
this is for the id.
your url must be like this:

url(r'^events/((?P<id>\d+))/delete/$', views.delete_event, name='delete_event'),



you also need to give an amount in your template to the id:




action="{% url 'cal:delete_event' id=an_event_id %}">



On Saturday, April 29, 2017 at 1:08:46 AM UTC+4:30, Will Holmes wrote:
Hey all,

Can anyone tell me the (probably quite obvious) reason my reverse match isn't working?

Template:
<form method="post" action="{% url 'cal:delete_event' id %}">
  <input class="btn btn-primary btn-md" id="event-delete" type="submit" value="Delete">
</form>

Url:
url(r'^events/(\d+)/delete_event$', views.delete_event, name='delete_event'),

View:
def delete_event(request, id):
    Events.objects.filter(id=id).delete()
    return redirect("cal:home")

Also, if anyone can tell me a good way to get my delete button I'd be very grateful. 

Cheers,

Will

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/336a6a05-f6d0-4029-879c-b5d65f396210%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment