-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: new checker: hard-coded usage of auth.User/User.objects #244
Comments
I think this should be part of pylint-django |
I think this makes a lot of sense, pylint and pylint-django is as much about good practices as about finding errors. |
This seems like something good to add, and to enable by default, as it would be echoing the design recommendations of the Django documentation itself. |
atodorov
added a commit
that referenced
this issue
Jul 22, 2020
Original implementation by myself from https://github.com/kiwitcms/Kiwi/
atodorov
added a commit
that referenced
this issue
Jul 22, 2020
Original implementation by myself from https://github.com/kiwitcms/Kiwi/
atodorov
added a commit
that referenced
this issue
Jul 22, 2020
Original implementation by myself from https://github.com/kiwitcms/Kiwi/
This was referenced Oct 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Django recommends that you do not use the
User
model directly. Neither to issue queries against it, nor to use it as a foreign key reference. Instead you should be using theget_user_model()
function and theAUTH_USER_MODEL
setting.The reason for all of this is that this can be overridden and applications which do not hard-code the values are in theory more portable downstream. That is they can be used directly inside an environment where the User model has been overridden.
In another project of mine we have a simple checker which warns for both of the above scenarios: https://github.com/kiwitcms/Kiwi/blob/master/kiwi_lint/auth_user.py
Questions are:
pylint_django.checkers.db_performance
?Please vote and comment for your preferences.
The text was updated successfully, but these errors were encountered: