X
X
xenophobia2017-07-14 23:28:34
Django
xenophobia, 2017-07-14 23:28:34

How to make Django-registration and abstract user friends?

Redefined the user model,

class User(AbstractUser):
    balance = models.IntegerField(default=0, verbose_name='Баланс')
    usergroups = models.ForeignKey(UserGroup, verbose_name='Группа', blank=True, null=True)

django-registration says Manager isn't available when registering; 'auth.User' has been swapped for 'personalarea.User'
In settings.py the following is displayed: It is displayed normally in the admin panel, createsuperuser works, but not when registering. I looked at the django-registration sources, get_user_model is used there, in theory it should refer to the desired model. Error in views.py:
AUTH_USER_MODEL = 'personalarea.User'
def dispatch(self, *args, **kwargs):
    if not self.registration_allowed():
        return redirect(self.disallowed_url)
    return super(RegistrationView, self).dispatch(*args, **kwargs)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Kazantsev, 2017-07-15
@saintbyte

AUTH_USER_MODEL = 'personalarea.User'

This should have been done in the first migration.

K
ksenofobius, 2017-07-15
@ksenofobius

Added to the form (RegistrationForm) in Meta model = User, it worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question