django custom admin for User model code example

Example 1: Django Custom User Model

ChangeSwappableModel(
    setting="AUTH_USER_MODEL",
    old="auth.User",
    new="my_auth.User"
)

Example 2: Django Custom User Model

./manage.py shell
>>>
>>> from django.contrib.admin.models import LogEntry
>>> from django.contrib.contenttypes.models import ContentType
>>>
>>> auth_user = ContentType.objects.get(app_label='auth', model='user')
>>> accouts_user = ContentType.objects.get(app_label='Accounts', model='user')
>>>
>>> for le in LogEntry.objects.filter(content_type=auth_user):
...     le.content_type = accouts_user
...     le.save()
...

Tags:

Misc Example