1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #24334 -- Allowed admin password reset to work with non-digit custom user model primary key.

Thanks Loic for help and Simon for review.
This commit is contained in:
Tim Graham
2015-02-12 12:14:19 -05:00
parent f287bec583
commit fdf20093e0
3 changed files with 74 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.urls import urlpatterns
site = admin.AdminSite(name='custom_user_admin')
class CustomUserAdmin(UserAdmin):
def log_change(self, request, object, message):
# LogEntry.user column doesn't get altered to expect a UUID, so set an
# integer manually to avoid causing an error.
request.user.pk = 1
super(CustomUserAdmin, self).log_change(request, object, message)
site.register(get_user_model(), CustomUserAdmin)
urlpatterns += [
url(r'^admin/', include(site.urls)),
]