2015-02-12 17:14:19 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
2018-12-07 22:52:28 +00:00
|
|
|
from django.urls import path
|
2015-02-12 17:14:19 +00:00
|
|
|
|
|
|
|
site = admin.AdminSite(name="custom_user_admin")
|
|
|
|
|
|
|
|
|
|
|
|
class CustomUserAdmin(UserAdmin):
|
2021-05-19 19:07:48 +00:00
|
|
|
def log_change(self, request, obj, message):
|
2015-02-12 17:14:19 +00:00
|
|
|
# LogEntry.user column doesn't get altered to expect a UUID, so set an
|
|
|
|
# integer manually to avoid causing an error.
|
2015-09-03 00:50:34 +00:00
|
|
|
original_pk = request.user.pk
|
2015-02-12 17:14:19 +00:00
|
|
|
request.user.pk = 1
|
2021-05-19 19:07:48 +00:00
|
|
|
super().log_change(request, obj, message)
|
2015-09-03 00:50:34 +00:00
|
|
|
request.user.pk = original_pk
|
2015-02-12 17:14:19 +00:00
|
|
|
|
2016-11-12 17:11:23 +00:00
|
|
|
|
2015-02-12 17:14:19 +00:00
|
|
|
site.register(get_user_model(), CustomUserAdmin)
|
|
|
|
|
2015-05-19 09:10:04 +00:00
|
|
|
urlpatterns = [
|
2018-12-07 22:52:28 +00:00
|
|
|
path("admin/", site.urls),
|
2015-02-12 17:14:19 +00:00
|
|
|
]
|