Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgraded django.contrib.auth to be compatible with time zone support.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 03cfad41986c91298e32d081a29d3c361098de5f 1 parent 4ac594f
Aymeric Augustin aaugustin authored
10 django/contrib/auth/
@@ -1,4 +1,3 @@
-import datetime
import urllib
from django.core.exceptions import ImproperlyConfigured
@@ -7,6 +6,7 @@
from django.db.models.manager import EmptyManager
from django.utils.encoding import smart_str
from django.utils.translation import ugettext_lazy as _
+from django.utils import timezone
from django.contrib import auth
from django.contrib.auth.signals import user_logged_in
@@ -21,7 +21,7 @@ def update_last_login(sender, user, **kwargs):
A signal receiver which updates the last_login date for
the user logging in.
- user.last_login =
+ user.last_login =
@@ -91,7 +91,7 @@ def create_user(self, username, email=None, password=None):
Creates and saves a User with the given username, email and password.
- now =
+ now =
# Normalize the address by lowercasing the domain part of the email
# address.
@@ -181,8 +181,8 @@ class User(models.Model):
is_staff = models.BooleanField(_('staff status'), default=False, help_text=_("Designates whether the user can log into this admin site."))
is_active = models.BooleanField(_('active'), default=True, help_text=_("Designates whether this user should be treated as active. Unselect this instead of deleting accounts."))
is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_("Designates that this user has all permissions without explicitly assigning them."))
- last_login = models.DateTimeField(_('last login'),
- date_joined = models.DateTimeField(_('date joined'),
+ last_login = models.DateTimeField(_('last login'),
+ date_joined = models.DateTimeField(_('date joined'),
groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True,
help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in."))
user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True)
3  django/contrib/auth/tests/
@@ -4,6 +4,7 @@
from django.contrib.auth.backends import RemoteUserBackend
from django.contrib.auth.models import User
from django.test import TestCase
+from django.utils import timezone
class RemoteUserTest(TestCase):
@@ -80,6 +81,8 @@ def test_last_login(self):
user = User.objects.create(username='knownuser')
# Set last_login to something so we can determine if it changes.
default_login = datetime(2000, 1, 1)
+ if settings.USE_TZ:
+ default_login = default_login.replace(tzinfo=timezone.utc)
user.last_login = default_login
Please sign in to comment.
Something went wrong with that request. Please try again.