Django non unique username field warning

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.


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

链接地址: http://www.djcxy.com/p/33696.html

上一篇: 如何使用django

下一篇: Django非唯一的用户名字段警告