Is there a built-in login template in Django?

前端 未结 6 1828
臣服心动
臣服心动 2020-12-12 11:48

I want to let a user sign in before seeing pages. Is there any built-in template for user sign in, so that I do not have to write my own sign in page?

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 12:15

    Quick and dirty.

    Suppose, for example, you're working on a re-usable app that requires login functionality, but does not implement its own.

    If, for the time being, you do not want to bother with custom login (views, forms, templates, urls, and so on), you can simply specify the admin login page as LOGIN_URL in settings.py (docs):

    ...
    
    LOGIN_URL = '/admin/login/'
    
    ...
    

    Beware: One serious drawback is that you can only log in with a staff account (or superuser).

提交回复
热议问题