我的应用程序托管在shezankazi.pythonanywhere.com
上当我打开此链接时,我会访问index.html。但是我想直接打开login.html,就像我选择" Anmelden"在索引页面。因此我需要帮助
这是我的views.py
def index(request):
return render(request, 'crm/index.html')
class MyRegistrationView(RegistrationView):
def get_success_url(self, request, user):
return '/crm/'
这是我的app / urls.py
from django.conf.urls import url
from django.conf.urls import include
from django.contrib import admin
from crm import views as crm_views
from person import views as person_views
urlpatterns = [
url(r'^$', crm_views.index, name='index'),
url(r'^crm/', include('crm.urls')),
...
]
这是我的crm / urls.py
from django.conf.urls import url
from crm import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^dashboard/', views.dashboard, name='dashboard'),
]
这是我的settings.py:
的结尾# If True, users can register
REGISTRATION_OPEN = False
# One-week activation window; you may, of course, use a different value.
ACCOUNT_ACTIVATION_DAYS = 7
# If True, the user will be automatically logged in.
REGISTRATION_AUTO_LOGIN = False
# The page you want users to arrive at after they successful log in
LOGIN_REDIRECT_URL = '/crm/dashboard/'
# The page users are directed to if they are not logged in,
# and are trying to access pages requiring authentication
LOGIN_URL = '/accounts/login/'
# The page users are directed to upon logging out
LOGOUT_REDIRECT_URL = '/accounts/login'
首先我更改了索引视图以呈现registration / login.html但是每当我输入我的凭据时,登录页面再次加载而不是将我重定向到仪表板。
答案 0 :(得分:1)
更改以下两行的顺序:
url(r'^$', views.index, name='index'),
url(r'^dashboard/', views.dashboard, name='dashboard'),,
并更改以下内容:
return '/crm/dashboard/'