-
Notifications
You must be signed in to change notification settings - Fork 58
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
Allow configuration parameters to be read from settings.py #198
Comments
Hey, I'm wondering mainly about two things:
2/ What API for the Django settings options? Two suggestions are:
b/ a dict with all options:
My preference goes to option b/ in order to less pollute the constants and keep the values grouped together organically - but open to discussions here :) Here is a PR with the above suggestions #199 |
Great points here, I completely agree with you! Especially the “environment-specific” part.
I’m with you about polluting settings.pay with a bunch of first-class settings. But consider this - what does discovery look like? If you have them all on the parent level if I’m in Pycharm I believe I can type MIGRATION_LINTER in settings.py and then hit ctrl+space to pull up auto completion for all the settings. I think you lose that with a dict in a single setting. On the other hand, the dict can be the exact same keys as the config file so it’s not too hard to look at the docs and copy/paste the right keys. Finally, it might be possible to fix the autocompletion with a more first-class little dataclass object that represents the settings, and then you could type-hint the actual setting with that dataclass. Python 3.8+ has a nice TypedDict which could also work, maybe something to put in userland and not in this library. So there’s the bike shed but what you’ve got in the PR is great!! Thanks so much @David-Wobrock!! |
Thanks for the input Phillip! |
@David-Wobrock good call! Thanks again for the addition! Any thought towards what release this will land in and when? |
I hope to tackle one or two open issues and then release 4.0.0 :) 🤞 |
For my use case we have some people that use Docker as a development environment and some that don't. This means the project root path could be /Users/phillip/projects/my_project (for me running on macOS) or /usr/src/my_project when inside of Docker. It would be nice if we could compute this config value through something like settings.py.
Perhaps there are other use cases for config to involve computation. Maybe there could be another option for reading configs and they could be considered in the following order:
So command line arguments always take precedence over anything else.
Originally brought up in #167 (comment), copied here.
The text was updated successfully, but these errors were encountered: