diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html
index 114f98c369..41514e6a81 100644
--- a/django/contrib/admin/templates/admin/base.html
+++ b/django/contrib/admin/templates/admin/base.html
@@ -20,9 +20,9 @@
{% block branding %}{% endblock %}
- {% if not user.is_anonymous %}{% if user.is_staff %}
+ {% if user.is_authenticated and user.is_staff %}
- {% endif %}{% endif %}
+ {% endif %}
{% block nav-global %}{% endblock %}
diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py
index 250c585220..fce50909f0 100644
--- a/django/contrib/admin/views/decorators.py
+++ b/django/contrib/admin/views/decorators.py
@@ -46,7 +46,7 @@ def staff_member_required(view_func):
member, displaying the login page if necessary.
"""
def _checklogin(request, *args, **kwargs):
- if not request.user.is_anonymous() and request.user.is_staff:
+ if request.user.is_authenticated() and request.user.is_staff:
# The user is valid. Continue to the admin page.
if request.POST.has_key('post_data'):
# User must have re-authenticated through a different window
diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py
index bc8ec39115..222c311e9c 100644
--- a/django/contrib/auth/decorators.py
+++ b/django/contrib/auth/decorators.py
@@ -17,7 +17,7 @@ def user_passes_test(test_func, login_url=LOGIN_URL):
return _checklogin
return _dec
-login_required = user_passes_test(lambda u: not u.is_anonymous())
+login_required = user_passes_test(lambda u: u.is_authenticated())
login_required.__doc__ = (
"""
Decorator for views that checks that the user is logged in, redirecting
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index cca3c62252..c201fc6232 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -125,6 +125,11 @@ class User(models.Model):
def is_anonymous(self):
"Always returns False. This is a way of comparing User objects to anonymous users."
return False
+
+ def is_authenticated(self):
+ """Always return True. This is a way to tell if the user has been authenticated in templates.
+ """
+ return True
def get_full_name(self):
"Returns the first_name plus the last_name, with a space in between."
@@ -293,3 +298,6 @@ class AnonymousUser(object):
def is_anonymous(self):
return True
+
+ def is_authenticated(self):
+ return False
diff --git a/django/contrib/comments/templates/comments/form.html b/django/contrib/comments/templates/comments/form.html
index 4a6b5fc320..c5aa7686a3 100644
--- a/django/contrib/comments/templates/comments/form.html
+++ b/django/contrib/comments/templates/comments/form.html
@@ -2,10 +2,10 @@
{% if display_form %}