-
使用
驗證一組憑據。它將憑據作為關鍵字參數,默認情況下為authenticate()username和password,針對每個身份驗證後端檢查它們,如果憑據對後端有效,則返回對象。如果憑證對任何後端都無效,或者後端引發User,則返回PermissionDeniedNone。例如:from django.contrib.auth import authenticate user = authenticate(username='john', password='secret') if user is not None: # A backend authenticated the credentials else: # No backend authenticated the credentialsrequest是可選的,它通過身份驗證後端的HttpRequestauthenticate()方法傳遞。注意
這是驗證一組憑據的低級方法;例如,它被
使用。除非您正在編寫自己的身份驗證係統,否則您可能不會使用它。相反,如果您正在尋找登錄用戶的方法,請使用RemoteUserMiddleware。LoginView
本文介紹 django.contrib.auth.authenticate 的用法。
聲明
authenticate(request=None, **credentials)
相關用法
- Python Tableau auth.sign_in用法及代碼示例
- Python Tableau auth.sign_out用法及代碼示例
- Python Tableau auth.switch_site用法及代碼示例
- Python arcgis.gis._impl._profile.ProfileManager.save_as用法及代碼示例
- Python arcgis.raster.functions.ccdc_analysis用法及代碼示例
- Python arcgis.geometry.functions.trim_extend用法及代碼示例
- Python arcgis.raster.analytics.sample用法及代碼示例
- Python arcgis.features.analysis.derive_new_locations用法及代碼示例
- Python arcgis.features.analyze_patterns.calculate_density用法及代碼示例
- Python arcgis.geometry.Geometry.label_point用法及代碼示例
- Python ast.MatchClass用法及代碼示例
- Python arcgis.plan_routes用法及代碼示例
- Python arcgis.mapping.forms.FormInfo用法及代碼示例
- Python arcgis.gis.UserManager.get用法及代碼示例
- Python arcgis.raster.ImageryLayerCacheManager.update_tiles用法及代碼示例
- Python arcgis.geometry.Geometry.true_centroid用法及代碼示例
- Python arcgis.gis.User.generate_direct_access_url用法及代碼示例
- Python arcgis.gis.GroupMigrationManager.create用法及代碼示例
- Python arcgis.geometry.Geometry.hull_rectangle用法及代碼示例
- Python arcgis.features.analysis.summarize_within用法及代碼示例
- Python arcgis.geometry.filters.intersects用法及代碼示例
- Python arcgis.geometry.functions.project用法及代碼示例
- Python abc.ABCMeta用法及代碼示例
- Python arcgis.raster.functions.percentile用法及代碼示例
- Python arcgis.raster.ImageryLayer.save用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.contrib.auth.authenticate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
