Opened 17 years ago

Closed 17 years ago

Last modified 14 years ago

#5049 closed (wontfix)

[PATCH] Application settings import

Reported by: Joshua 'jag' Ginsberg <jag@…> Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

We develop lots of utility applications that include many customizable configuration settings. Installing them all and modifying settings.py to include all of the settings makes our settings.py complex and unwieldly. Thus we felt that these application-specific settings should be pushed out to settings.py files in each specific application so that the defaults are always defined, and to allow each project/site to override these application defaults by creating <app_name>.py in a project subfolder called app_settings.

This is best described with an example. My project in this example is skwx and my app is cienfuegos.

$ ./manage.py shell
Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import os
>>> os.listdir('/srv/skwx')
['manage.py', '__init__.py', 'settings.py', 'urls.py', 'svn', 'cienfuegos', '__init__.pyc', 'django.db', 'app_settings', 'settings.py~', 'settings.pyc']
>>> os.listdir('/srv/skwx/cienfuegos')
['views.py', '__init__.py', 'models.py~', '__init__.pyc', 'svn-post-commit.py~', 'svn-post-commit.py', 'models.py', 'models.pyc', 'settings.py', 'settings.py~', 'settings.pyc']
>>> os.listdir('/srv/skwx/app_settings')
['__init__.py', 'cienfuegos.py', '__init__.pyc', 'cienfuegos.pyc']
>>> print open('/srv/skwx/cienfuegos/settings.py').read()
FOO='bar'
bar='baz'
WTF='ZOMFG!'
>>> print open('/srv/skwx/app_settings/cienfuegos.py').read()
FOO='not bar'
>>> from django.conf import settings
>>> settings.cienfuegos.FOO
'not bar'
>>> settings.cienfuegos.WTF
'ZOMFG!'

Please let me know if you feel this could be appropriate for inclusion. Thanks!

-jag

Attachments (1)

django-settings.patch (3.3 KB ) - added by Joshua 'jag' Ginsberg <jag@…> 17 years ago.
Patch to django/conf/init.py

Download all attachments as: .zip

Change History (3)

by Joshua 'jag' Ginsberg <jag@…>, 17 years ago

Attachment: django-settings.patch added

Patch to django/conf/init.py

comment:1 by Russell Keith-Magee, 17 years ago

Resolution: wontfix
Status: newclosed

As noted in the mailing list; this idea has come up in the past (search the archives) and we've decided against it.

comment:2 by Eric Holscher, 14 years ago

Refs #1371

Note: See TracTickets for help on using tickets.
Back to Top