[Answer]-View takes exactly 2 arguments (1 given)

0👍

✅

Like the error message says, you’re only passing one variable to the function, when it’s expecting two. Assuming that request_id is required for your function to work you’ll have to modify your urls.py so that it captures the request_id from the URL and passes it to the view.

This simple example should give you an idea how to go about it:

urls.py

urlpatterns = patterns('',
    url(r'^(?P<slug>[\w\-]+)/$', 'base.views.index'),
)

views.py

def index(request, slug=None):
    if slug is not None:
        return HttpResponse(slug)
    else:
        return HttpResponse("No slug provided")

It’s basically a case of wrapping your regex in (?INSERT_REGEX_HERE) tag, so in your case it would be:

(?P<request_id>Req_.*)

1👍

Try this:

url(r'^request/(?P<request_id>Req_.*)/someoperation/',include(someoperation.urls))

Leave a comment