我认为这是盯着代码太久的情况,但我无法解析这个 URL。我正在使用 Django 1.5.5。
这是主要的urls.py
:
from django.conf.urls import patterns, include, url
from django.views.generic import RedirectView
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', RedirectView.as_view(url='/swap/')),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^swap/$', include('apps.swap.urls')),
url(r'^admin/swap/', include('apps.swap.admin_urls')),
url(r'^admin/', include(admin.site.urls)),
)
这是我的应用程序url.py
:
from django.conf.urls import patterns, url
from apps.swap.views import About
urlpatterns = patterns('apps.swap.views',
url(r'^$', 'index'),
url(r'^about/$', About.as_view()),
)
所有 URL 都解析(包括/swap/
)除了/swap/about/
. 它只是拒绝解决。这就是我所看到的:
Using the URLconf defined in urlconf, Django tried these URL patterns, in this order:
1. ^__debug__/sql_select/$ [name='sql_select']
2. ^__debug__/sql_explain/$ [name='sql_explain']
3. ^__debug__/sql_profile/$ [name='sql_profile']
4. ^__debug__/template_source/$ [name='template_source']
5. ^$
6. ^admin/doc/
7. ^swap/$
8. ^admin/swap/
9. ^admin/
The current URL, swap/about/, didn't match any of these.
我在这里想念什么?我知道这一定很简单,但在昨晚 16 小时的编码弯曲之后,我想我已经失明了。