Всем привет! Возникла ошибка, помогите пожалуйста разобраться. Создал свою модель пользователя, свою форму, вьюшку и бэкэнд соответсвенно. Регистрация пользователя проходит, а залогиниться не получается. Записи в БД есть, проверил.

Вот трейс:

AttributeError at /login/ 'UserStandardRegister' object has no attribute 'backend'

Request Method: POST
Request URL:    http://127.0.0.1:8000/login/
Django Version: 1.9.6
Exception Type: AttributeError
Exception Value:    
'UserStandardRegister' object has no attribute 'backend'
Exception Location: /home/jaroslav/.virtualenvs/python3-venv-development/lib/python3.4/site-packages/django/contrib/auth/__init__.py in login, line 112
Python Executable:  /home/jaroslav/.virtualenvs/python3-venv-development/bin/python
Python Version: 3.4.2

Traceback Switch to copy-and-paste view

/home/jaroslav/.virtualenvs/python3-venv-development/lib/python3.4/site-packages/django/core/handlers/base.py in get_response
                    response = self.process_exception_by_middleware(e, request) ...

/home/jaroslav/.virtualenvs/python3-venv-development/lib/python3.4/site-packages/django/core/handlers/base.py in get_response
                    response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
            request.session.flush()
    else:
        request.session.cycle_key()
    request.session[SESSION_KEY] = user._meta.pk.value_to_string(user)
    request.session[BACKEND_SESSION_KEY] = user.backend
    request.session[HASH_SESSION_KEY] = session_auth_hash
    if hasattr(request, 'user'):
        request.user = user
    rotate_token(request)
    user_logged_in.send(sender=user.__class__, request=request, user=user)

request.session[BACKEND_SESSION_KEY] = user.backend - на на эту строку ругается

Вот код:

view.py

def signin(request):
if request.user.is_authenticated():
    return HttpResponseRedirect('/address/')

if request.method == 'POST':
    form = UserStandardLoginForm(request.POST)

    if form.is_valid():
        username = form.cleaned_data.get('username')
        password = form.cleaned_data.get('password')

        model_backend = UserStandardModelBackend()

        user_standard_authenticate = model_backend.authenticate(username=username, password=password)
        if user_standard_authenticate is not None:
            login(request, user_standard_authenticate)

            return HttpResponseRedirect('/address/')
        else:
            return render_to_response('signin.html', {'form': form}, context_instance=RequestContext(request))
    else:
        return render_to_response('signin.html', {'form': form}, context_instance=RequestContext(request))
else:
    form = UserStandardLoginForm()
    context = {'form': form}

    return render_to_response('signin.html', context, context_instance=RequestContext(request))

backend.py

class UserStandardModelBackend(ModelBackend):
    def authenticate(self, username=None, password=None, **kwargs):
        try:
            user = self.user_class.objects.get(username=username)
            if user.check_password(password):
                return user
        except self.user_class.DoesNotExist:
            return None

    def get_user(self, user_id):
        try:
            user = self.user_class.objects.get(pk=user_id)
            if user.is_active:
                return user
            else:
                return None
        except self.user_class.DoesNotExist:
            return None

    @property
    def user_class(self):
        if not hasattr(self, '_user_class'):
            self._user_class = apps.get_model(*settings.CUSTOM_USER_MODEL.split('.', 2))
            if not self._user_class:
                raise ImproperlyConfigured(_('Could not get custom user model.'))

        return self._user_class

model.py

class UserManagerStandardRegister(BaseUserManager):
    use_in_migrations = True

    def __create_user__(self, whatname, username, password=None, **extra_fields):
        if not whatname or not username:
            raise ValueError(_('The given whatname and username must be set.'))

        user = self.model(whatname=whatname, username=username, **extra_fields)
        user.set_password(password)
        user.save(using=self._db)

        return user

    def create_user(self, whatname, username, password=None, **extra_fields):
        return self.__create_user__(whatname, username, password, **extra_fields)


@python_2_unicode_compatible
class UserStandardRegister(AbstractBaseUser, PermissionsMixin):
    whatname = models.CharField(
        _('whatname'),
        max_length=254,
        db_column=_('whatname'),
        validators=[
            validators.RegexValidator(
                r'^[\w]+$',
                _('Enter a valid whatname. This value may contain only '
                  'letters, numbers and characters.')
            ),
        ],
        error_messages={
            'whatname_empty': _('A user with that whatname value is not be empty.'),
        }
    )

    username = models.CharField(
        _('username'),
        max_length=254,
        unique=True,
        db_column=_('username'),
        validators=[
            validators.EmailValidator(
                _('Enter a valid username. This value may contain only '
                  'letters, numbers and @/./_/ characters.')
            ),
        ],
        error_messages={
            'username_unique': _('A user with that username already exists.'),
        }
    )

    uuid = models.UUIDField(
        _('uuid'),
        max_length=32,
        blank=True,
        null=True,
        db_column='uuid'
    )

    is_staff = models.BooleanField(
        _('is_staff'),
        default=False,
        db_column='is_staff',
    )

    is_active = models.BooleanField(
        _('is_active'),
        default=True,
        db_column='is_active',
    )

    date_joined = models.DateTimeField(
        _('date_joined'),
        auto_now_add=True,
        db_column='date_joined',
    )

    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = []

    objects = UserManagerStandardRegister()

    class Meta:
        swappable = 'AUTH_USER_MODEL'

        # verbose_name = _('user')
        # verbose_name_plural = _('users')

        db_table = _('auth_user_std')

    def get_short_name(self):
        pass

    def get_full_name(self):
        pass

    def get_uuid(self):
        return self.uuid

    def get_whatname(self):
        return self.whatname.strip()

    def __unicode__(self):
        return self.whatname