2012-02-08 4 views
1

ワーキングを使用して:ジャンゴのURLディスパッチャの問題プレフィックス

urlpatterns = patterns('', 
    (r'^$', views.index), 
    (r'^test/$|test/(\d+)/$', views.test_page), 
    (r'^(name)/$', views.index), 
    (r'^(username)/$', views.index), 
) 

に動作していない:

urlpatterns = patterns('views', 
    (r'^$', index), 
    (r'^test/$|test/(\d+)/$', test_page), 
    (r'^(name)/$', index), 
    (r'^(username)/$', index), 
) 

エラー:私はどこ

Django Version:  1.3 
Exception Type:  NameError 
Exception Value: name 'index' is not defined 
Exception Location: /home/nolhian/Documents/Test/../test/urls.py in <module>, line 8 

を、私は、これを行うためにドキュメントを追いましたうまくいかない ?

答えて

5

あなたは接頭辞を使用する場合は、文字列として、あなたのビューを指定する必要があります。

urlpatterns = patterns('views', 
    (r'^$', 'index'), 
    (r'^test/$|test/(\d+)/$', 'test_page'), 
    (r'^(name)/$', 'index'), 
    (r'^(username)/$', 'index'), 
) 
+0

はそんなに私はそれを逃したありがとう! – Nolhian

関連する問題