File tree 5 files changed +43
-11
lines changed
5 files changed +43
-11
lines changed Original file line number Diff line number Diff line change @@ -72,3 +72,5 @@ apache/static/*
72
72
73
73
# Sphinx documentation
74
74
docs /build /
75
+
76
+ config_local.py
Original file line number Diff line number Diff line change @@ -89,17 +89,34 @@ DATABASES = {
89
89
}
90
90
```
91
91
92
- # Production deployment checklist
92
+ # Specifying settings file
93
+
94
+ 0 . By default, website.settings.dev is used for manage.py and website.settings.prod is used in wsgi.py
95
+ It is typically required to change default settings file used in manage.py in production and qa enviroments
96
+
97
+ 1 . Exporting DJANGO_SETTINGS_MODULE variable
98
+
99
+ This method works well on the command line, but it doesn't seem to work with apache - SetEnv doesn't seem to have any effect when mod_wsgi
100
+ is initalizing wsgi application object.
101
+
102
+ 2 . Creating config_local.py in the root folder (next to wsgi.py and manage.py)
103
+
104
+ Note if DJANGO_SETTINGS_MODULE is defined, it takes precedence over settings_module in config_local.py
93
105
94
- 1 . Change database to PostgreSQL in settings_local.py
106
+ Example:
107
+ ``` python
108
+ settings_module = " website.settings.qa"
109
+ ```
110
+ Check wsgi.py and manage.py to see how it works - they are different from default versions generated by Django.
111
+
112
+
113
+ # Production deployment checklist
95
114
96
- 2 . Set DEBUG to False in settings_local .py
115
+ 1 . Copy config_local_example.py to config_local .py
97
116
98
- 3 . Generate new SECRET_KEY
99
-
100
- 4 . Change ALLOWED_HOSTS and ADMINS accordingly
117
+ 2 . Generate new SECRET_KEY in settings_local.py
101
118
102
- 5 . Set APP_ENV to 'production'
119
+ 3 . Enable VecNet SSO
103
120
104
121
# Enable VecNet SSO
105
122
Original file line number Diff line number Diff line change
1
+ settings_module = "website.settings.prod"
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
import os
3
3
import sys
4
+ try :
5
+ from config_local import settings_module
6
+ settings_module_message = "as defined in config_local.py file. DJANGO_SETTINGS_MODULE is ignored."
7
+ except ImportError :
8
+ settings_module = "website.settings.dev"
9
+ settings_module_message = ""
4
10
5
11
if __name__ == "__main__" :
6
- os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "website.settings.dev" )
12
+ os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , settings_module )
7
13
8
14
from django .core .management import execute_from_command_line
9
-
10
- execute_from_command_line (sys .argv )
15
+ print ( "manage.py: Using settings: %s %s" % ( os . environ . get ( "DJANGO_SETTINGS_MODULE" ), settings_module_message ))
16
+ execute_from_command_line (sys .argv )
Original file line number Diff line number Diff line change 7
7
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
8
8
"""
9
9
10
+
10
11
import os
11
12
12
13
from django .core .wsgi import get_wsgi_application
13
14
14
- os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "website.settings.prod" )
15
+ try :
16
+ from config_local import settings_module
17
+ except ImportError :
18
+ settings_module = "website.settings.prod"
19
+
20
+ os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , settings_module )
15
21
16
22
application = get_wsgi_application ()
You can’t perform that action at this time.
0 commit comments