Skip to content

Using UserAdmin with AbstractBaseUser #2878

@Superpat

Description

@Superpat

Bug report

What's wrong

I cant use UserAdmin for a user that's based on AbstractBaseUser and I cant import BaseUserAdmin.

saskatoon/member/admin.py:50: error: Type argument "AuthUser" of "UserAdmin" must be a subtype of "AbstractUser"  [type-var]
ImportError: cannot import name 'BaseUserAdmin' from 'django.contrib.auth.admin' (/app/.tox/mypy/lib/python3.9/site-packages/django/contrib/auth/admin.py)

The class declaration is as such:

class AuthUserAdmin(UserAdmin[AuthUser]):

See https://github.com/LesFruitsDefendus/saskatoon-ng/blob/mypy_django/saskatoon/member/admin.py for the actual file.

How is that should be

I dont know what I'm supposed to do.

System information

  • OS: debian bullseye
  • python version: 3.9.23
  • django version: 3.2.25
  • mypy version: 1.15.0
  • django-stubs version: 5.1.3
  • django-stubs-ext version: 5.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions