Changeset 990
- Timestamp:
- 10/21/05 19:18:39 (3 years ago)
- Files:
-
- django/trunk/docs/authentication.txt (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/authentication.txt
r989 r990 54 54 * ``is_superuser`` -- Boolean. Designates whether this user has permission 55 55 to do anything (according to the permission system). 56 * ``last_login`` -- A datetime of the user's last login. Is set to "now" by57 default.56 * ``last_login`` -- A datetime of the user's last login. Is set to the 57 current date/time by default. 58 58 * ``date_joined`` -- A datetime designating when the account was created. 59 Is set to "now"by default when the account is created.59 Is set to the current date/time by default when the account is created. 60 60 61 61 Methods … … 119 119 ~~~~~~~~~~~~~~~~ 120 120 121 The ``django.models. users`` module has the following helper functions:121 The ``django.models.auth.users`` module has the following helper functions: 122 122 123 123 * ``create_user(username, email, password)`` -- Creates, saves and returns … … 209 209 210 210 from django.utils.httpwrappers import HttpResponseRedirect 211 211 212 def my_view(request): 212 213 if request.user.is_anonymous(): … … 214 215 # ... 215 216 216 ...or display ingan error message::217 ...or display an error message:: 217 218 218 219 def my_view(request): … … 227 228 228 229 from django.views.decorators.auth import login_required 230 229 231 def my_view(request): 230 232 # ... 231 233 my_view = login_required(my_view) 232 234 233 Here's the same , using Python 2.4's decorator syntax::235 Here's the same thing, using Python 2.4's decorator syntax:: 234 236 235 237 from django.views.decorators.auth import login_required 238 236 239 @login_required 237 240 def my_view(request): … … 264 267 265 268 from django.views.decorators.auth import user_passes_test 269 266 270 @user_passes_test(lambda u: u.has_perm('polls.can_vote')) 267 271 def my_view(request): … … 270 274 ``user_passes_test`` takes a required argument: a callable that takes a 271 275 ``User`` object and returns ``True`` if the user is allowed to view the page. 276 Note that ``user_passes_test`` does not automatically check that the ``User`` 277 is not anonymous. 272 278 273 279
