Source

django-environments / bin / djenvlib

Diff from to

bin/djenvlib

 # to newline to get to those:
 # IFS='
 # '
-# Note that all variables are prefixed with value of $prefix, 'DJANGO_'.
+# Note that all variables are prefixed with 'DJANGO_'.
 function import_django_settings() {
     _verify_project_root || return 1
     _verify_django_settings_module || return 1
 
     prefix=DJANGO_
     python << EOF
-import $DJANGO_SETTINGS_MODULE as settings
+from django.conf import settings
 from types import TupleType, ListType, DictType
 
 def escape(value):
     return str(value).replace('"', '\\\\"')
 
-settings = settings.__dict__.items()
-settings.sort()
-for name, value in settings:
-    if name.find('__') == -1 and name.find('$1') == 0:
+prefix = '$1'.upper()
+for name in sorted(dir(settings)):
+    if name.isupper() and name.find('__') == -1 and name.find(prefix) == 0:
+        value = getattr(settings, name)
         if type(value) in (TupleType, ListType):
             print '$prefix%s="' % name
             for item in value:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.