저는 장고를 처음 사용하고 djangobook.com을 사용하고 있습니다. 동적 URL 예제를 시도했지만 TypeError를 제공합니다. 무엇이 잘못되었는지 보시겠습니까?Django 기본 사항 : 동적 URL은 TypeError를 제공합니다
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),
)
모든/로컬 호스트/이름/
하지만/로컬 호스트/이름으로 이동/플러스/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 개의 인수, 하나 주어진"에 의해 의미합니다 .. arugments은 요청 및 오프셋입니다 ... 그리고 내부적으로 get과 함께 전달 요청 아닌가요?
편집 :
이것은 base.html가
<html>
<title> Test Project </title>
<body>
Hello {{ name }}
</body>
</html>
링크는 localhost/name 등으로 작성되어 있으므로 http : //127.0 등으로 입력 할 수 없습니다. – user1349663