Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:43:22+00:00 2026-06-18T10:43:22+00:00

AUTH_USER_MODEL error solved in EDIT3. Passwords still will not save on user creation via

  • 0

AUTH_USER_MODEL error solved in EDIT3. Passwords still will not save on user creation via form.

I’m using Django 1.5 playing around with the new user override/extension features, and I am not able to register new users via my registration form – only via the Admin. When registering via the registration form, I get the following error:

Manager isn't available; User has been swapped for 'poker.PokerUser'

models.py:

class PokerUser(AbstractUser):
    poker_relate = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True)
    token = models.EmailField()
    USER_CHOICES = (
        ('1', 'Staker'),
        ('2', 'Horse')
    )
    user_type = models.CharField(choices=USER_CHOICES, max_length=10)
    username1 = models.CharField(null=True, blank=True, max_length=40)
    username2 = models.CharField(null=True, blank=True, max_length=40)
    username3 = models.CharField(null=True, blank=True, max_length=40)
    username4 = models.CharField(null=True, blank=True, max_length=40)
    username5 = models.CharField(null=True, blank=True, max_length=40)

PokerUserForm model:

class PokerUserForm(UserCreationForm):
    class Meta:
        model = PokerUser
        fields = ('username','password1','password2','email','user_type','token','username1','username2','username3','username4','username5',)

I’ve attempted to change the model in the PokerUserForm model to use get_user_model() instead of explicitly defining the model by setting model = get_user_model() instead of model = PokerUser but then I receive the following error:

django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'poker.PokerUser' that has not been installed

My AUTH_USER_MODEL is setup in my settings.py like so:

AUTH_USER_MODEL = 'poker.PokerUser'

On we go – my Registration view in views.py:

def UserRegistration(request):
    player = PokerUser()

    if request.method == 'POST':
        form = PokerUserForm(request.POST, instance=player)
        if form.is_valid():
            player.email_address = form.cleaned_data['email']
            player.user_type = form.cleaned_data['user_type']
            # if player is staker, token is their own email. otherwise their token is their staker's email and
            # their relation is their staker
            if player.user_type == '1' or player.user_type == 'staker':
                player.token = player.email_address
            else:
                player.token = form.cleaned_data['token']
                staker = PokerUser.objects.get(email=player.token)
                player.poker_relate = staker
            player.save()
            return HttpResponseRedirect('/')
    else:
        form = PokerUserForm()
    initialData = {'form': form}
    csrfContext = RequestContext(request, initialData)
    return render_to_response('registration/register.html', csrfContext)

EDIT1:

According to the docs, the UserCreationForm must be recreated for use with custom user classes.

I overrode the entire UserCreationForm as follows:

class UserCreationForm(forms.ModelForm):
    """
    A form that creates a user, with no privileges, from the given username and
    password.
    """
    error_messages = {
        'duplicate_username': _("A user with that username already exists."),
        'password_mismatch': _("The two password fields didn't match."),
        }
    username = forms.RegexField(label=_("Username"), max_length=30,
        regex=r'^[\w.@+-]+$',
        help_text=_("Required. 30 characters or fewer. Letters, digits and "
                    "@/./+/-/_ only."),
        error_messages={
            'invalid': _("This value may contain only letters, numbers and "
                         "@/./+/-/_ characters.")})
    password1 = forms.CharField(label=_("Password"),
        widget=forms.PasswordInput)
    password2 = forms.CharField(label=_("Password confirmation"),
        widget=forms.PasswordInput,
        help_text=_("Enter the same password as above, for verification."))

    class Meta:
        model = PokerUser
        fields = ('username','password1','password2','email','user_type','token','username1','username2','username3','username4','username5',)

    def clean_username(self):
        # Since User.username is unique, this check is redundant,
        # but it sets a nicer error message than the ORM. See #13147.
        username = self.cleaned_data["username"]
        try:
            PokerUser.objects.get(username=username)
        except PokerUser.DoesNotExist:
            return username
        raise forms.ValidationError(self.error_messages['duplicate_username'])

    def clean_password2(self):
        password1 = self.cleaned_data.get("password1")
        password2 = self.cleaned_data.get("password2")
        if password1 and password2 and password1 != password2:
            raise forms.ValidationError(
                self.error_messages['password_mismatch'])
        return password2

    def save(self, commit=True):
        user = super(UserCreationForm, self).save(commit=False)
        user.set_password(self.cleaned_data["password1"])
        if commit:
            user.save()
        return user

And this was able to resolve this error:

The Manager isn't available; User has been swapped for 'poker.PokerUser'

Now, the users get created but are not able to log in. When I check the users in the admin, all of the information seems to be correct except for the password. Adding a password manually in the admin does not seem to work correctly. Still, adding users via the admin work correctly.

EDIT 2:

I’m still unable to login as any of my AbstractUser models created via the registration form. I have completely overridden the UserCreationForm as outlined above, and am unable to implement
get_user_model() with this error:

AUTH_USER_MODEL refers to model 'poker.PokerUser' that has not been installed

The Django code for get_user_model() is:

 def get_user_model():
    "Return the User model that is active in this project"
    from django.conf import settings
    from django.db.models import get_model

    try:
        app_label, model_name = settings.AUTH_USER_MODEL.split('.')
    except ValueError:
        raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form 'app_label.model_name'")
    user_model = get_model(app_label, model_name)
    if user_model is None:
        raise ImproperlyConfigured("AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL)
    return user_model

Since I have AUTH_USER_MODEL = 'poker.PokerUser' setup in my settings.py, this should work. I’ve verified this through the Django console:

>>> from django.contrib.auth import get_user_model
>>> settings.AUTH_USER_MODEL
Out[14]: 'poker.PokerUser'
>>> from django.db.models import get_model
>>> app_label, model_name = settings.AUTH_USER_MODEL.split('.')
>>> user_model = get_model(app_label, model_name)
>>> user_model
Out[18]: poker.models.PokerUser

However the implementation still does not work correctly.

If you’ve read this far, thanks!

EDIT3:

AUTH_USER_MODEL refers to model 'poker.PokerUser' that has not been installed has been fixed. I accidentally had the UserCreationForm that I recreated in poker.models instead of registration.forms, so when I ran get_user_model() that was assigned to poker.PokerUser, it couldn’t resolve since it was already in that location.

Now the only issue left is that when creating new users, their passwords will not save. I’ve narrowed it down to a single method in the UserCreationForm by placing print statements here:

def clean_password2(self):
    password1 = self.cleaned_data.get("password1")
    print password1
    password2 = self.cleaned_data.get("password2")
    print password2
    if password1 and password2 and password1 != password2:
        raise forms.ValidationError(
            self.error_messages['password_mismatch'])
    print password2
    return password2

def save(self, commit=True):
    user = super(UserCreationForm, self).save(commit=False)
    user.set_password(self.cleaned_data["password1"])
    print self.cleaned_data["password1"]
    if commit:
        user.save()
    return user

The print password1 and print password1 statements in clean_password2 display the plain text password, but print self.cleaned_data["password1"] in the save method is blank. Why is my form data not being passed to the save method?

TL;DR AbstractUser model creation is working in both Admin and via registration form, but only the users created via Admin are able to login. The users created via the registration form are unable to log in and seem to be saved without a password – all other information is saved correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:43:23+00:00Added an answer on June 18, 2026 at 10:43 am

    Ok there were three issues here for me, so I’m going to address all of them since I am pretty sure the first two will come up for someone else.

    • Manager isn't available; User has been swapped for 'poker.PokerUser'

    This was due to using but not recreating the UserCreationForm. When using custom models in 1.5, some model forms are available out of the box but this one must be recreated. See here for the docs.

    • The Manager isn't available; User has been swapped for 'poker.PokerUser'

    While I had AUTH_USER_MODEL = 'poker.PokerUser' set in my settings.py, I was calling get_user_model() from the poker.models location. You must call get_user_model() from a different location. Moving my form to registration.forms and calling get_user_model() from there worked correctly.

    • New users not saving

    This was just a brain fart on my end. In my UserRegistration model I was manipulating various fields from the form. When I passed those fields back to UserCreationForm for the save() method, I was not passing the password fields with it. Woops!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form like so: from django import forms from django.contrib.auth.models import User
I inherited form the django user model like so: from django.db import models from
I'm attempting to extend django's contrib.auth User model, using an inline 'Profile' model to
I am using Django 1.3/Python 2.7. My application is using django.contrib.auth for User management.
I got strange error message when tried to save first_name, last_name to Django's auth_user
I am using django-postman to provide user-to-user message facility and this uses django ajax-selects
It looks like Django does not update last_login field in auth_user model when a
from django.contrib.auth.models import User u = User.objects.get(username='test') user.password u'sha1$c6755$66fc32b05c2be8acc9f75eac3d87d3a88f513802 Is reversing this password encryption
Following works fine in shell: >>> from django.contrib.auth.models import User >>> user=User.objects.get(pk=1) >>> user.first_name
How can I set the Basic Auth user id and password when using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.