-
使用
验证一组凭据。它将凭据作为关键字参数,默认情况下为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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
