Created
April 15, 2020 22:13
-
-
Save turicas/f3f363cc3ea0975f0ae9998250c3ff3d to your computer and use it in GitHub Desktop.
Check Django username conflict (case senstive)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Check conflicts in Django usernames | |
This script checks every username for a possible conflict, due to Django's default policy | |
to accept `user` and `User` as different usernames. | |
""" | |
from django.contrib.auth import get_user_model | |
from tqdm import tqdm | |
User = get_user_model() | |
conflict_usernames = set() | |
for user in tqdm(User.objects.all(), total=User.objects.count()): | |
if User.objects.filter(username=user.username).count() > 1: | |
conflict_usernames.add(user.username.lower()) | |
print(f"Total usernames in conflict: {len(conflict_usernames)}") | |
for username in sorted(conflict_usernames): | |
print(f" - {username}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment