-
來自
:AuthenticationMiddleware的一個實例,代表當前的 logged-in 用戶。如果用戶當前未登錄,AUTH_USER_MODELuser將設置為的實例。您可以使用AnonymousUser將它們區分開來,如下所示:is_authenticatedif request.user.is_authenticated: ... # Do something for logged-in users. else: ... # Do something for anonymous users.
本文介紹 django.http.HttpRequest.user 的用法。
聲明
HttpRequest.user
相關用法
- Python Django HttpRequest.accepts用法及代碼示例
- Python Django HttpRequest.headers用法及代碼示例
- Python Django HttpRequest.get_signed_cookie用法及代碼示例
- Python Django HttpRequest.method用法及代碼示例
- Python Django HttpRequest.__iter__用法及代碼示例
- Python Django HttpRequest.build_absolute_uri用法及代碼示例
- Python Django Http404用法及代碼示例
- Python calendar HTMLCalendar formatmonth()用法及代碼示例
- Python HTMLCalendar formatyearpage()用法及代碼示例
- Python calendar HTMLCalendar formatyear()用法及代碼示例
- Python HTMLCalendar formatyear()用法及代碼示例
- Python HTMLCalendar formatmonth()用法及代碼示例
- Python HTML轉Markdown用法及代碼示例
- Python calendar HTMLCalendar formatyearpage()用法及代碼示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python numpy.less()用法及代碼示例
- Python Matplotlib.figure.Figure.add_gridspec()用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python Django File.save用法及代碼示例
- Python Sympy Permutation.list()用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.http.HttpRequest.user。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
