0
0
mirror of https://github.com/django/django.git synced 2024-11-30 23:20:50 +01:00
django/tests/auth_tests/urls_custom_user_admin.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
680 B
Python
Raw Normal View History

from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from django.urls import path
site = admin.AdminSite(name="custom_user_admin")
class CustomUserAdmin(UserAdmin):
def log_change(self, request, obj, message):
# LogEntry.user column doesn't get altered to expect a UUID, so set an
# integer manually to avoid causing an error.
original_pk = request.user.pk
request.user.pk = 1
super().log_change(request, obj, message)
request.user.pk = original_pk
2016-11-12 18:11:23 +01:00
site.register(get_user_model(), CustomUserAdmin)
urlpatterns = [
path("admin/", site.urls),
]