我想将url(r'^', include('article.urls')),
放在urlpatterns列表的末尾,因为在urlpatterns之后我有MEDIA_ROOT
的网址:
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT}))
所以我需要url(r'^', include('article.urls'))
成为最后一个。
我试过了
urlpatterns += patterns('', (r'^'), include('article.urls'),
)
但它不起作用。
主urls.py
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'firstapp.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^redactor/', include('redactor.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^basicview/', include('article.urls')),
url(r'^auth/', include('loginsys.urls')),
url(r'^', include('article.urls')),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT}))
文章urls.py
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'firstapp.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^articles/$', 'article.views.articles'),
url(r'^articles/(?P<article_id>\d+)/$', 'article.views.article'),
url(r'^articles/addlike/(?P<article_id>\d+)/$', 'article.views.addlike'),
url(r'^articles/addcomment/(?P<article_id>\d+)/$', 'article.views.addcomment'),
url(r'^page/(\d+)/$', 'article.views.articles'),
url(r'^', 'article.views.mainPage'),
)
答案 0 :(得分:0)
您可能需要urls.py
:
url(r'^.*', include('article.urls')),
在你的article.urls.py
中你需要这个:
url(r'^.*', 'article.views.mainPage'),
您可以查看此question & answer