我希望在从我的仪表板页面浏览链接时,该 url 应该是/dashboard/link
. 当我写url(r'dashboard/inbox/','apps.dashboard.views.inbox', name = 'grabhalo_inbox'),
它时,它确实会读取我views
提供的论点。
相反,当我编写时,url(r'inbox/','apps.dashboard.views.inbox', name = 'grabhalo_inbox'),
我得到了预期的输出,但 url 是/inbox
. 我想要的是/dashboard/inbox
。
我哪里错了?
这是我的根urls.py文件
urlpatterns = patterns('',
(r'^',include('apps.auth.urls')),
(r'^',include('apps.dashboard.urls')),
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}),
url(r'^admin/', include(admin.site.urls)),
)
这是我的dashboard.urls.py
urlpatterns = patterns('',
url(r'dashboard/','apps.dashboard.views.dashboard', name = 'grabhalo_dashboard'),
url(r'sent/','apps.dashboard.views.sent', name = 'grabhalo_sent'),
url(r'inbox/','apps.dashboard.views.inbox', name = 'grabhalo_inbox'),
)