You have hit a salient point in Django. It indeed is a mess how every third 
party
application must add its own configuration classes in order to make their 
own
default settings configurable through a settings.py. This results in 
settings directives
which can have any attribute name and do not follow any namespacing.

Some external apps, such as easy-thumbnails 
<https://easy-thumbnails.readthedocs.io/en/latest/> add their own configuration 
framework 
<https://github.com/SmileyChris/easy-thumbnails/blob/master/easy_thumbnails/conf.py>
with many different setting attributes, while others such as DRF use one 
Python dictionary
to keep all configurations in one closed namespace. The latter in my 
opinion is the
better approach but has its own issues. Having a consistent naming 
convention of setting
attributes, and a reconfiguration framework would certainly be beneficial 
in Django.

In my opinion, just switching to JSON does not resolve these naming 
convention issues,
but adds a bunch of other problems:

*Some configuration settings must be lazy.*
For instance, ugettext_lazy is used very often in the setting.py. This 
can't be handled by JSON.

*Writing JSON by hand is harder than writing Python.*
An alternative would be the usage of yaml or toml.

*Some settings must be taken from the environment.*
Especially database passwords and the SECRET_KEY shall be injected through 
the environment.
Typically here one would use os.getenv('DJANGO_SECRET_KEY') or similar. 
This can't be
handled by JSON either.

On Monday, December 30, 2019 at 11:46:03 PM UTC+1, Christian González wrote:
>
>
> * read json settings (if they exist), use them 
> * load settings.py which allows to override them again (using some 
> special code tricks like dynamic loading, environments etc.) 
>
>
If implemented, wouldn't it make more sense to use a JSON file to override 
a settings.py
rather than doing it vice versa? 

– just my two cents,
Jacob

-- 
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/f5d9a23a-2927-454e-a3d3-6d2361c3aa06%40googlegroups.com.

Reply via email to