[Django]-Django _view_() takes 1 positional argument but 2 were given

10👍

As stated in the error message, your view needs to take a second parameter:

def user(request, second_param):
    return render(request, 'home/user_page.html')

This is because you added a group in the regex (the part between parenthesis) and Django passes any matched group as arguments to the view.

If you prefer the previous behaviour, remove the parenthesis from your regex:

r'^users/[a-zA-Z0-9.]+/$'

Relevant documentation: https://docs.djangoproject.com/en/1.9/topics/http/urls/#how-django-processes-a-request

👤aumo

Leave a comment