1
- from django .conf import settings
2
- from django .contrib .admin import ModelAdmin
3
-
4
1
VERSION = '0.1.0'
5
2
6
- # Reverse default actions position
7
- ModelAdmin .actions_on_top = False
8
- ModelAdmin .actions_on_bottom = True
9
3
10
4
def default_config ():
11
5
return {
@@ -27,7 +21,7 @@ def default_config():
27
21
'MENU_ICONS' : {
28
22
'auth' : 'icon-lock' ,
29
23
'sites' : 'icon-leaf' ,
30
- },
24
+ },
31
25
# 'MENU_ORDER': (
32
26
# ('sites',),
33
27
# ('auth', ('user','group')),
@@ -38,20 +32,32 @@ def default_config():
38
32
}
39
33
40
34
41
- def get_config (param = None ):
42
- config_key = 'SUIT_CONFIG'
43
- if hasattr (settings , config_key ):
44
- config = getattr (settings , config_key , {})
45
- else :
46
- config = default_config ()
47
- if param :
48
- value = None
49
- if param in config :
50
- value = config .get (param )
51
- if value is None :
52
- value = default_config ().get (param )
53
- return value
54
- return config
55
-
56
- # Set global list_per_page
57
- ModelAdmin .list_per_page = get_config ('LIST_PER_PAGE' )
35
+ from os import getenv
36
+
37
+ if getenv ('DJANGO_SETTINGS_MODULE' , None ):
38
+
39
+ from django .contrib .admin import ModelAdmin
40
+ from django .conf import settings
41
+
42
+ def get_config (param = None ):
43
+
44
+ config_key = 'SUIT_CONFIG'
45
+ if hasattr (settings , config_key ):
46
+ config = getattr (settings , config_key , {})
47
+ else :
48
+ config = default_config ()
49
+ if param :
50
+ value = None
51
+ if param in config :
52
+ value = config .get (param )
53
+ if value is None :
54
+ value = default_config ().get (param )
55
+ return value
56
+ return config
57
+
58
+ # Reverse default actions position
59
+ ModelAdmin .actions_on_top = False
60
+ ModelAdmin .actions_on_bottom = True
61
+
62
+ # Set global list_per_page
63
+ ModelAdmin .list_per_page = get_config ('LIST_PER_PAGE' )
0 commit comments