Skip to content

Commit 5ad0b28

Browse files
committed
import apps settings in project settings. Apps settings can define a REQUIRED_APPS parameter that will be appended to INSTALLED_APPS
1 parent 14958a0 commit 5ad0b28

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These apps will automatically be added to the INSTALLED_APPS
2+
# of a Djity instance that uses this Djity application
3+
REQUIRED_APPS = []

djity/project_skeleton/settings.py_tmpl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,25 @@ try:
216216
except:
217217
pass
218218

219-
# add activated djity modules and services to installed apps
220-
if len (DJITY_APPS) >= 0:
221-
INSTALLED_APPS += DJITY_APPS
222-
219+
# try importing djity apps, add them to installed apps if successful and fetch their settings
220+
for app in DJITY_APPS:
221+
try:
222+
app_mod = import_module(app)
223+
INSTALLED_APPS.append(app)
224+
except:
225+
warn("no app '%s' found." % app)
226+
continue
227+
try:
228+
exec("from %s.settings import *" % app)
229+
except ImportError,e:
230+
warn("no settings found for app '%s'" % app)
231+
continue
232+
try:
233+
required_apps = import_module(app+'.settings').REQUIRED_APPS
234+
INSTALLED_APPS += required_apps
235+
except:
236+
warn("no REQUIRED_APPS parameter found in %s.settings" % app)
237+
continue
223238

224239
# import and overwrite all settings defined locally
225240
try:

0 commit comments

Comments
 (0)