Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django non unique username field warning

Tags:

python

django

In my django app I have a custom user model with a username field called my_username. Recently I made this field non unique (actually it is now unique_together with another field). This makes django to emit the following warning in manage.py:

(auth.W004) 'MyUser.my_username' is named as the 'USERNAME_FIELD', but it is not unique. HINT: Ensure that your authentication backend(s) can handle non-unique usernames.

Is there a way to prevent this warning for displaying? I only found ways to disable all warnings, but I want to disable only that specific one.

like image 542
Tzach Avatar asked Sep 30 '22 12:09

Tzach


1 Answers

Since Django 1.7, there is a setting to silence certain warnings. If you are using Django 1.7 or later, you can add the error code to the SILENCED_SYSTEM_CHECKS setting:

# settings.py

SILENCED_SYSTEM_CHECKS = ["auth.W004"]

source: https://docs.djangoproject.com/en/dev/ref/settings/#silenced-system-checks

like image 138
nKandel Avatar answered Oct 02 '22 14:10

nKandel