Handle custom Django settings module
Instead of using a standard settings.py, I use a settings folder with an __init__.py, which imports settings conditionally depending on my deployment environment. This seems to have rendered PyCharm unable to detect many of my settings. Does PyCharm attempt to actually import settings.py or to parse it? It seems to me that doing the former would allow it to handle most nonstandard settings setups, as long as things don't get too crazy. But besides some conditional importing, my settings are all just regular variables at the end of the day, and my settings don't depend on any non-standard library modules, so it seems like it should be workable.
Please sign in to leave a comment.
However, I've found a workaround that may work for you, too:
In Project Settings > Django Support, instead of choosing your __init__.py, choose your production.py profile, or equivalent. Then at least PyCharm is actually able to retrieve your settings for template paths, databases etc.
Then for all Django Run Configurations, make sure to add "–settings=myproject.settings" to Additional Options, so that you can run with the correct settings module.
Hope that helps.