# HG changeset patch # User Gustavo Andres Morero # Date 1567611274 10800 # Wed Sep 04 12:34:34 2019 -0300 # Node ID ffc17226f424f3526e5fd5d9a831492decfa8e4b # Parent 7447c7ba1d04d07d4b290cbc211c6217cd90dbb8 some updates for auth.User references. diff --git a/webutils/baseacct/forms.py b/webutils/baseacct/forms.py --- a/webutils/baseacct/forms.py +++ b/webutils/baseacct/forms.py @@ -1,6 +1,6 @@ from django import forms from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.contrib.auth.forms import AuthenticationForm from django.utils.translation import ugettext_lazy as _ @@ -14,7 +14,8 @@ def clean_email(self): if 'email' in self.cleaned_data: email = self.cleaned_data['email'] - if not User.objects.filter(email__iexact=email).count() > 0: + if not get_user_model().objects.filter( + email__iexact=email).count() > 0: raise forms.ValidationError( u'There is no account registered to this email address.' ) @@ -65,4 +66,4 @@ def save(self): self.user.set_password(self.cleaned_data['new_password']) - self.user.save() \ No newline at end of file + self.user.save() diff --git a/webutils/baseacct/models.py b/webutils/baseacct/models.py --- a/webutils/baseacct/models.py +++ b/webutils/baseacct/models.py @@ -1,9 +1,12 @@ +from django.db import models from django.conf import settings -from django.db import models -from django.contrib.auth.models import UserManager, User +from django.contrib.auth import get_user_model +from django.contrib.auth.models import UserManager from django.utils.translation import ugettext_lazy as _ from webutils.djtools.email import send_simple_email +User = get_user_model() + class BaseUserProfileManager(UserManager): def generate_hash(self): @@ -69,7 +72,7 @@ class BaseUserProfile(models.Model): user = models.ForeignKey( - User, + setting.AUTH_USER_MODEL, unique=True, verbose_name=_('User Account'), help_text=_('User Profiles must be "tied" to a user account.'), diff --git a/webutils/baseacct/views.py b/webutils/baseacct/views.py --- a/webutils/baseacct/views.py +++ b/webutils/baseacct/views.py @@ -1,8 +1,7 @@ from django.conf import settings -from django.contrib.auth.models import User +from django.shortcuts import render, redirect +from django.template import loader, RequestContext from django.contrib.auth.decorators import login_required -from django.template import loader, RequestContext -from django.shortcuts import render, redirect def reset(request, reset_form, profile_model, template, key=None): diff --git a/webutils/djtools/auth_backends.py b/webutils/djtools/auth_backends.py --- a/webutils/djtools/auth_backends.py +++ b/webutils/djtools/auth_backends.py @@ -1,5 +1,7 @@ from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model + +User = get_user_model() class EmailBackend(object):