-
-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: UserAdmin accepts AbstractUser #1783
Conversation
|
||
class GroupAdmin(admin.ModelAdmin[Group]): ... | ||
|
||
class UserAdmin(admin.ModelAdmin[User]): | ||
class UserAdmin(admin.ModelAdmin[_M], Generic[_M]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class UserAdmin(admin.ModelAdmin[_M], Generic[_M]): | |
class UserAdmin(admin.ModelAdmin[_M]): |
I do not think the Generic is needed.
from django.http.request import HttpRequest | ||
from django.http.response import HttpResponse | ||
|
||
csrf_protect_m: Any | ||
sensitive_post_parameters_m: Any | ||
_M = TypeVar("_M", bound=AbstractUser, covariant=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_M = TypeVar("_M", bound=AbstractUser, covariant=False) | |
_M = TypeVar("_M", bound=AbstractUser) |
covariant is False by default I think.
@@ -1,16 +1,17 @@ | |||
from typing import Any | |||
from typing import Any, Generic, TypeVar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from typing import Any, Generic, TypeVar | |
from typing import Any, TypeVar |
As per below comments, I do not think this is needed.
Hey @GabDug, thanks for your PR. Do you plan to address comments or I can do it for you and open new PR? I need this also. |
Shouldn't this be checking for inheritance from |
I have made things!
Fix an issue I introduced with UserAdmin: if you inherit from it with a custom
User
it would not work, only with Django baseUser
.If needed, can add a test case akin of:
and
Any feedback is appreciated!
Related issues