简体   繁体   中英

Customize Django login page

i'm using django.contrib.auth to auth. user. I'm using default login view, but i would like to add some more things (for example displaying number of already loge users). Is there any way to customize that view or i have to copy-paste it to my project and chage some things inside that? Is there are any way to call two views on one url?

Remember, views are functions. You can write your own view that calls Django's login view at the end:

def mylogin(request):
    ...
    return login(request, 'my-login-template.html')

The kind of customization you want can happen in the template.

The default login view doesn't provide a way to extend the template's context, you'll have to use a context processor for that, or write your own view and calling the login function instead, but that would mean writing more code which can introduce bugs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM