以下にリストされているプロジェクトmyproject
とアプリがありmyapp
ます。URL を試すと、次の/add
エラーが表示されます。
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/add/
Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order:
^$
The current URL, add/, didn't match any of these.
設定構成:
ROOT_URLCONF = 'myproject.urls'
myproject/urls.py
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^$', include('myapp.urls')),
)
myapp/urls.py
from django.conf.urls import patterns, include, url
urlpatterns = patterns('myapp.views',
url(r'^$', 'main'),
url(r'^add/', 'foo'),
)
myapp/views.py
from django.shortcuts import render
def main(request):
return render(request, "main.html", {'test': 1})
def foo(request):
return render(request, "add.html")
テンプレート/main.html
{{ test }}
テンプレート/add.html
{{ test }}
なにが問題ですか?