I have this error on Django view:
TypeError at /web/host/1/
decorator() got an unexpected keyword argument 'host_id'
Request Method: GET
Request URL: http://127.0.0.1:8000/web/host/1/edit
Django Version: 1.10.4
Exception Type: TypeError
Exception Value:
decorator() got an unexpected keyword argument 'host_id'
and the urlpatterns is:
url(r'^host/(?P<host_id>[0-9]+)$', host, name='host'),
the view function is :
@check_login
def host(request, host_id, *args, **kwargs):
h = Host()
# resultHost = h.get_host(host_id)
return render(request, 'web/host.html')
check_login below:
def check_login(f):
"""verify if user login"""
def decorator(request):
if request.session.get('user', None):
return f(request)
else:
return HttpResponseRedirect(reverse("web:login"))
return decorator
if I use the url without parameter "host_id" and the host function without host_id, the program will run perfect.
so what's the problem? Thank you.