Skip to content
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

Enforcing django settings import format #434

Open
jarmstrong-atlassian opened this issue Sep 20, 2024 · 0 comments
Open

Enforcing django settings import format #434

jarmstrong-atlassian opened this issue Sep 20, 2024 · 0 comments

Comments

@jarmstrong-atlassian
Copy link

According to django's docs, settings should be imported using from django.conf import settings and not your own settings file; see https://docs.djangoproject.com/en/5.1/topics/settings/#using-settings-in-python-code

I recently ran into a bug in our dev environment where a setting gave an ImportError using from myapp.mymodule import MY_SETTING, apparently because that setting was defined using environment variables (I'm guessing there may be some lazy loading behavior here that is bypassed by importing the setting directly).

Since pylint-django knows about the application's settings module via DJANGO_SETTINGS_MODULE, would it be possible to flag the incorrect style of import by looking for that module in import statements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant