How can I not use Django's admin login view?

后端 未结 10 2654
借酒劲吻你
借酒劲吻你 2020-12-28 15:11

I created my own view for login. However if a user goes directly to /admin it brings them to the admin login page and doesn\'t use my custom view. How can I make it redirect

10条回答
  •  自闭症患者
    2020-12-28 15:29

    In your ROOT_URLCONF file (by default, it's urls.py in the project's root folder), is there a line like this:

    urlpatterns = patterns('',
    ...
        (r'^admin/', include(admin.site.urls)),
    ...
    )
    

    If so, you'd want to replace include(admin.site.urls) with the custom view you created:

    (r'^admin/', 'myapp.views.myloginview'),
    

    or if your app has its own urls.py, you could include it like this:

    (r'^admin/', include(myapp.urls)),
    

提交回复
热议问题