My two cents: JSON isn’t great as a configuration language - It’s annoyingly 
picky about some things. YAML or TOML are “better” (for some definition of 
better) choices for this domain, in my option. However, Django is historically 
quite hesitant about including third party packages and I think including a 
TOML or YAML parser even as an optional dependency might not be the way forward.

So rather than just “allowing people to use JSON files for settings” it would 
be very interesting to explore what a pluggable settings backend would look 
like. It seems that work in this area would be best spent on a general 
abstraction rather than a specific one. There was some discussion around this 
idea in the GSOC thread and I’m sure it’s come up before. Personally I think 
configuration management is an area of Django that is quite underdeveloped 
compared to other frameworks.

> On 30 Dec 2019, at 22:46, Christian González <christian.gonza...@nerdocs.at> 
> wrote:
> 
> Hello,
> 
> I recently "finished" my first really working version of GDAPS, my
> Generic Django Application Plugin System. It's noway perfect, but does
> what it should: providing pluggable apps for an app framework, including
> a more or less flexible frontend with each django app.
> 
> I had much struggle with it, and one of the lessons I learned was
> Django's setup system, and how it deals with loading apps. Unfortunately
> Django can't load/unload apps on the fly, so it is necessary to restart
> Django whenever a new GDAPS app is installed via pip.
> 
> But: I want to resurrect an old theme again which would, in a way,
> improve some of the loading problems I encountered. Django's settings
> are code. Which is, in fact, a very good thing, as it makes it extremely
> flexible and adaptable to different setups. But, as discussed with the
> SECRET_KEY here, some of the settings _have_ to be coded very
> complicated, and it makes some things like per-app-settings extremely
> uncomfortable.
> 
> What if - and please don't kill me instantly - yes, I am a newcomer, and
> not a good programmer maybe - but some things are viewed better from
> "outside" - what if Django settings could be "declarative"?
> 
> So instead of Python code like
> 
> INSTALLED_APPS = [
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes'
> ]
> 
> This would be in an e.g. JSON file
> 
> {
> 
>     "INSTALLED_APPS": [
>         "django.contrib.admin",
>         "django.contrib.auth",
>         "django.contrib.contenttypes"
>     ] ,
>     ROOT_URLCONF: "fooproject.urls"
> }
> 
> Django's settings.py would look different: It would load that
> settings.json file and set the appropriate values into local code - so
> this wouldn't make much difference.
> 
> Except 2 things:
> 
> 1. Apps could have (default) settings, and they could be merged MUCH
> easier. Things like namespaced classes that are overwriting values like
> DRF/graphene does, would be completely unnecessary. The main
> settings.json file could be the "last word" in the process of settings,
> so anything an app would suggest could be overrided in the main file.
> 
> 2. Installed apps could be managed much more comfortable. Adding an app
> could be done by a script (JSON editing is easy. Editing code
> (=settings.py) is error prone and uncomfortable). I have a Django
> command script ATM for that, but just because I add a line into
> settings.py to add some additional apps to the list.
> 
> This even could be done with backwards compatibility, because Django
> would keep it's settings.py file optionally:
> 
> * 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.)
> 
> Please tell me what you think about that.
> 
> Christian
> 
> 
> --
> Dr. Christian González
> https://nerdocs.at
> 
> --
> 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/3047a7b6-3fa0-d574-4bb6-7842b7aed44a%40nerdocs.at.
> <pEpkey.asc>

-- 
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/D7000C61-69C0-4E59-9DB8-4BB1413B0C98%40tomforb.es.

Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to