Ticket #3029: contrib_auth_date_fields_errors_v2.patch

File contrib_auth_date_fields_errors_v2.patch, 2.0 KB (added by Tim Goh <timgoh@…>, 18 years ago)

against r4085

  • backends.py

     
    11from django.contrib.auth.models import User
     2import datetime
    23
    34class ModelBackend:
    45    """
     
    1011        try:
    1112            user = User.objects.get(username=username)
    1213            if user.check_password(password):
     14                # User has been authenticated; update user's last login datetime
     15                user.last_login = datetime.datetime.now()
     16                user.save()
    1317                return user
    1418        except User.DoesNotExist:
    1519            return None
  • models.py

     
    9595    is_staff = models.BooleanField(_('staff status'), default=False, help_text=_("Designates whether the user can log into this admin site."))
    9696    is_active = models.BooleanField(_('active'), default=True, help_text=_("Designates whether this user can log into the Django admin. Unselect this instead of deleting accounts."))
    9797    is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_("Designates that this user has all permissions without explicitly assigning them."))
    98     last_login = models.DateTimeField(_('last login'), default=models.LazyDate())
    99     date_joined = models.DateTimeField(_('date joined'), default=models.LazyDate())
     98    last_login = models.DateTimeField(_('last login'), auto_now_add=True)
     99    date_joined = models.DateTimeField(_('date joined'), auto_now_add=True)
    100100    groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True,
    101101        help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in."))
    102102    user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True, filter_interface=models.HORIZONTAL)
Back to Top