Skip to content

Instantly share code, notes, and snippets.

@tuatara
tuatara / admin.py
Last active April 7, 2021 21:23
Allow case-insensitive usernames with Django & Postgres
# Add the mixin to the default admin objects
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin as ContribUserAdmin
from django.contrib.auth.forms import UserChangeForm as ContribUserChangeForm, \
UserCreationForm as ContribUserCreationForm
from accounts.forms import CaseInsensitiveUsernameMixin # adjust if forms.py is not in `accounts` app
class UserChangeForm(CaseInsensitiveUsernameMixin, ContribUserChangeForm):

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.