網址另一個應用程序的文件,我已經在我的項目,學院和學生兩個應用程序。我已經在根網址文件中包含了研究所應用程序的網址。包括一個應用程序的URL轉換成在Django
根urls.py
urlpatterns += [
url(r'^insti/', include('institute.urls', namespace='institute')),
]
研究所/ urls.py文件
from institute import views
from django.conf.urls import url, include
app_name = "institute"
# institute urls
urlpatterns = [
url(r'^$', views.institute_home, name='home'),
url(r'^signin/$', views.signin, name='signin'),
url(r'^logout/$', views.institute_logout, name='logout'),
# other urls here
]
# students urls in institute
urlpatterns += [
url(r'^student/', include('students.urls', namespace='students')),
]
學生/ urls.py文件
from django.conf.urls import url
from students import views
app_name = "students"
urlpatterns = [
url(r'^$', views.students_home, name="students_home"),
url(r'^register/$', views.register, name="register"),
url(r'^signin/$', views.signin, name="signin"),
url(r'^logout/$', views.students_logout, name="logout"),
# other urls
]
當我打像localhost/insti/sigin, localhost/insti/<anything>
網址,它工作正常,但只要我打的網址localhost/insti/students
它拋出我的錯誤
「學生」是不是已註冊的命名空間
的地方在我的代碼在線return HttpResponseRedirect(reverse("students:signin"))
是我的學生,包括在網址研究所的網址是錯誤的或有其他問題的方式?
學生應用不必須的網址登錄,不會在模板將是研究所:登入 – Exprator
它有登入網址。我省略了它。包括它。 – User42