mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[1.8.x] Fixed #25895 -- Used a consistent style for UserAdmin overrides.
Thanks Justin Abrahms for the report. Backport of 166e0490d39f619928ee9c5133cc5cab0ae5c1db from master
This commit is contained in:
parent
975a451153
commit
cdc354eb39
@ -329,7 +329,7 @@ add it to a ``UserAdmin`` class which is registered with the
|
|||||||
:class:`~django.contrib.auth.models.User` class::
|
:class:`~django.contrib.auth.models.User` class::
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
from my_user_profile_app.models import Employee
|
from my_user_profile_app.models import Employee
|
||||||
@ -342,7 +342,7 @@ add it to a ``UserAdmin`` class which is registered with the
|
|||||||
verbose_name_plural = 'employee'
|
verbose_name_plural = 'employee'
|
||||||
|
|
||||||
# Define a new User admin
|
# Define a new User admin
|
||||||
class UserAdmin(UserAdmin):
|
class UserAdmin(BaseUserAdmin):
|
||||||
inlines = (EmployeeInline, )
|
inlines = (EmployeeInline, )
|
||||||
|
|
||||||
# Re-register UserAdmin
|
# Re-register UserAdmin
|
||||||
@ -1052,7 +1052,7 @@ code would be required in the app's ``admin.py`` file::
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
from django.contrib.auth.forms import ReadOnlyPasswordHashField
|
from django.contrib.auth.forms import ReadOnlyPasswordHashField
|
||||||
|
|
||||||
from customauth.models import MyUser
|
from customauth.models import MyUser
|
||||||
@ -1103,7 +1103,7 @@ code would be required in the app's ``admin.py`` file::
|
|||||||
return self.initial["password"]
|
return self.initial["password"]
|
||||||
|
|
||||||
|
|
||||||
class MyUserAdmin(UserAdmin):
|
class UserAdmin(BaseUserAdmin):
|
||||||
# The forms to add and change user instances
|
# The forms to add and change user instances
|
||||||
form = UserChangeForm
|
form = UserChangeForm
|
||||||
add_form = UserCreationForm
|
add_form = UserCreationForm
|
||||||
@ -1131,7 +1131,7 @@ code would be required in the app's ``admin.py`` file::
|
|||||||
filter_horizontal = ()
|
filter_horizontal = ()
|
||||||
|
|
||||||
# Now register the new UserAdmin...
|
# Now register the new UserAdmin...
|
||||||
admin.site.register(MyUser, MyUserAdmin)
|
admin.site.register(MyUser, UserAdmin)
|
||||||
# ... and, since we're not using Django's built-in permissions,
|
# ... and, since we're not using Django's built-in permissions,
|
||||||
# unregister the Group model from admin.
|
# unregister the Group model from admin.
|
||||||
admin.site.unregister(Group)
|
admin.site.unregister(Group)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user