0

I have an "NoReverseMatch at ∕ " eception with exception value:

Reverse for 'listEvents' with keyword arguments '{'values': ''}' not found. 1 pattern(s) tried: ['events/events\\/(?P<values>[^/]+)\\/$']

The odd thing is that I do not recognize this part: events/events\\/(?P<values>[^/]+)\\/$

My JScode:

var categories ="{% url 'events:listEvents' values=string %}";

where string is a SQL query.

This is my URL

  path('events/<str:values>/', views.showRequestedEvents, name='listEvents')

And this is my view

def showRequestedEvents(request, values):
    events = serialize('geojson', Event.objects.raw(values))
    return HttpResponse(events, content_type='json')

I know that it is pretty basic and I have seen similar questions has been asked a lot, yet even after searching for about 2 hr I haven't figured it out, so help!

Please...

3
  • {'values': ''} is telling you that values is not set in the template context. ``NoReverseMatch at /` is telling you that it's the index view for / that is causing the problem.
    – Alasdair
    Commented Apr 13, 2018 at 14:20
  • To help you any further we probably need to see your urls.py and the full stacktrace of the error, and also which URL you are trying to access
    – Ralf
    Commented Apr 13, 2018 at 15:46
  • That isn't your view. The relevant view must be rendering the template that that tag is on. Commented Apr 13, 2018 at 18:31

1 Answer 1

1

I got it "fixed". Looks like python or django don't like JavaScript variables so I could not put it directly into the url but had to use replace like this:

var categories ="{% url 'events:listEvents' 12345 %}".replace(/12345/,string);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.