0
일치하지 않는 url 패턴이 있습니다. 이것은 내가 장고 튜토리얼에서 채택한 것이다. 아마 쉬운 일이지만, 나는 그것을 놓치고 있습니다.Django urlpatterns가 일치하지 않습니다
오류 :
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'))
views.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)
루트 URL conf를 표시 할 수 있습니까? – karthikr
url (r '^ sendemail /', include ('sendemail.urls')), ' – karthikr
'에'url (r '^ sendemail', 포함 ('sendemail.urls') 포함)을 변경하십시오. 그것은 그것을 고쳤다. 감사. – jmoneystl