-
要從視圖中登錄用戶,請使用
login()
HttpRequest
User
login()
請注意,匿名會話期間的任何數據集都會在用戶登錄後保留在會話中。
此示例顯示了如何同時使用
authenticate()
login()
from django.contrib.auth import authenticate, login def my_view(request): username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) # Redirect to a success page. ... else: # Return an 'invalid login' error message. ...
本文介紹 django.contrib.auth.login
的用法。
聲明
login(request, user, backend=None)
相關用法
- Python Django login_required用法及代碼示例
- Python PIL logical_and() and logical_or()用法及代碼示例
- Python PIL logical_xor() and invert()用法及代碼示例
- Python Django logout用法及代碼示例
- Python logging.handlers.SocketHandler.makePickle用法及代碼示例
- Python logging.Logger.debug用法及代碼示例
- Python logging.debug用法及代碼示例
- Python log10()用法及代碼示例
- Python logging.LogRecord用法及代碼示例
- Python locals()用法及代碼示例
- Python list remove()用法及代碼示例
- Python len()用法及代碼示例
- Python numpy string less_equal()用法及代碼示例
- Python calendar leapdays()用法及代碼示例
- Python ldexp()用法及代碼示例
- Python list轉string用法及代碼示例
- Python lzma.LZMACompressor()用法及代碼示例
- Python Functools lru_cache()用法及代碼示例
- Python scipy linalg.pinv2用法及代碼示例
- Python list insert()用法及代碼示例
- Python lists轉XML用法及代碼示例
- Python list pop()用法及代碼示例
- Python linecache.getline()用法及代碼示例
- Python list index()用法及代碼示例
- Python list sort()用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.contrib.auth.login。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。