錯誤:TypeError在/ confirmemail/amlqctnhel/confirmemail()只需要2個參數(給出1個),爲什麼?
TypeError at /confirmemail/amlqctnhel/
confirmemail() takes exactly 2 arguments (1 given)
Request Method: GET
Request URL: http://127.0.0.1:8000/confirmemail/amlqctnhel/
Django Version: 1.3.1
Exception Type: TypeError
Exception Value:
confirmemail() takes exactly 2 arguments (1 given)
Exception Location: /usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py in get_response, line 111
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path:
['/home/user1/djangoblog',
'/usr/lib/python2.6',
'/usr/lib/python2.6/plat-linux2',
'/usr/lib/python2.6/lib-tk',
'/usr/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload',
'/usr/local/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages/gst-0.10',
'/usr/lib/pymodules/python2.6',
'/usr/lib/pymodules/python2.6/gtk-2.0']
urls.py:
url(r'^confirmemail/[a-zA-Z0-9]{10}/$', 'blog.views.confirmemail'),
views.py:
def confirmemail(request,token):
user = Users.objects.get(email_token = token)
return render_to_response('confirmemail.html', {'user': user}, context_instance=RequestContext(request))
這將不勝感激,如果有人可以幫助我解決這個問題。謝謝。
非常感謝。我錯過了支架,對吧? – shibly
正確。您需要在您的URL正則表達式中使用捕獲組('([stuff])或'(?P [stuff])',否則Django將不知道如何填充您的視圖參數。 –