私は Django を使い始めたばかりで、djangobook.com を使用しています。動的 URL の例を試しましたが、TypeError が返されます。何が悪いかわかりますか?
ビュー.py
from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponse
import datetime
def nameOffset(request, offset):
print "in nameOffset"
t = get_template('base.html')
html = t.render(Context({'name':offset}))
return HttpResponse(html)
urls.py
from django.conf.urls import patterns, include, url
from MemberInterface.views import getName, nameOffset
urlpatterns = patterns('',
(r'^name/$', getName ),
(r'^name/plus/\d+/$', nameOffset ),
)
/localhost/name/ ですべて問題ありません
しかし、/localhost/name/plus/1/ に行くと、
TypeError at /name/plus/1/
nameOffset() takes exactly 2 arguments (1 given)
Request Method: GET Request URL: /localhost/name/plus/1/
Django Version: 1.5.1 Exception Type: TypeError Exception Value:
nameOffset() takes exactly 2 arguments (1 given)
「2つの引数、1つが与えられた」とはどういう意味ですか..引数はリクエストとオフセットです...そしてリクエストは get で内部的に渡されませんか?
編集:
これは base.html です
<html>
<title> Test Project </title>
<body>
Hello {{ name }}
</body>
</html>