I'm just getting started with Django and am using djangobook.com. I tried the dynamic URL examples but it is giving me a TypeError. Can you see what's wrong ?
views.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 ),
)
Everything is fine at /localhost/name/
But when I go to /localhost/name/plus/1/, I get
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)
What does it mean by "2 arguments, one given" .. the arugments are request and offset... and isn't request internally passed with the get ?
EDIT:
This is the base.html
<html>
<title> Test Project </title>
<body>
Hello {{ name }}
</body>
</html>