I've found a few questions here related to my issue, but I haven't found anything that has helped me resolve my issue. I'm using Python 2.7.5 and Django 1.8.dev20140627143448.
I have a view that's interacting with my database to delete objects, and it takes two arguments in addition to a request:
def delete_data_item(request, dataclass_id, dataitem_id):
form = AddDataItemForm(request.POST)
data_set = get_object_or_404(DataClass, pk=dataclass_id)
context = {'data_set': data_set, 'form': form}
data_item = get_object_or_404(DataItem, pk=dataitem_id)
data_item.delete()
data_set.save()
return HttpResponseRedirect(reverse('detail',
args=(dataclass_id,)))
The URL in myapp.urls.py looks something like this:
url(r'^(?P<dataclass_id>[0-9]+)/(?P<dataitem_id>[0-9]+)/delete_data_item/$',
views.delete_data_item, name='delete_data_item')
and the portion of my template relevant to the view is:
<a href="{% url 'delete_data_item' data_set.id data_item.id %}">DELETE</a>
Whenever I click on the DELETE link, django tells me that the request URL:
http://127.0.0.1:8000/myapp/5/%7B%%20url%20'delete_data_item'%20data_set.id%20data_item.id%20%%7D
doesn't match any of my URL patterns. What am I missing? The URL on which the DELETE links exist is myapp/(<dataclass_id>[0-9]+)/