一致しない URL パターンがあります。これは、Django チュートリアルから適応させたものです。おそらく簡単なことですが、私はそれを見逃しています。
エラー:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/sendemail/1
Using the URLconf defined in emailme.urls, Django tried these URL patterns, in this order:
1. ^sendemail ^$ [name='index']
2. ^sendemail ^(?P<msg_id>\d+)/$ [name='detail']
3. ^sendemail ^(?P<msg_id>\d+)/results/$ [name='results']
4. ^admin/
The current URL, sendemail/1, didn't match any of these.
models.py:
from django.db import models
class Choice(models.Model):
choice_text = models.CharField(max_length=200)
def __unicode__(self):
return self.choice_text
ルート urls.py:
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^sendemail', include('sendemail.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
urls.py:
from django.conf.urls import patterns, url
from sendemail import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^(?P<msg_id>\d+)/$', views.detail, name='detail'),
url(r'^(?P<msg_id>\d+)/results/$', views.results, name='results'))
ビュー.py:
from django.http import HttpResponse
def index(request):
return HttpResponse("You're at the index")
def detail(request, msg_id):
return HttpResponse("The details of message id %s" % msg_id)
def results(request, msg_id):
return HttpResponse("The results of message id %s" % msg_id)