On Tue, Nov 1, 2022 at 10:34 AM Florian Apolloner <f.apollo...@gmail.com> wrote:
> Right, that would work. I am wondering though if we want to go all in on a > typed config object like that or in a first step only have a simple API > like `config.get('DEBUG', cast=bool)`. > > I found a neat trick in a 12factor library somewhere (I don't remember where unfortunately) of using ast.literal_eval for config variables: https://docs.python.org/3/library/ast.html#ast.literal_eval https://github.com/matthiask/speckenv/blob/94722bcc95b94a9e6b1a1aada2bd977c43bfb767/speckenv.py#L63 This may be too cute or magical for Django. It certainly works well and avoids having to be overspecific with types. I find it boring to tell the config loader that True is a bool and "hello" is a string. That being said I don't really have a strong preference here apart from having a strong dislike for the "several settings files" pattern. It's much more obvious to me if e.g. `MIDDLEWARE` is configured in a single location and not modified in other files. Thanks, Matthias -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CANvPqgCTFEoO%2BG8-UNmHRPckto0DPoJb5-d596oexAc2kqxtNQ%40mail.gmail.com.