File tree Expand file tree Collapse file tree 3 files changed +22
-25
lines changed
Expand file tree Collapse file tree 3 files changed +22
-25
lines changed Original file line number Diff line number Diff line change 4545 owner : " {{ wsgi_user }}"
4646 group : " {{ wsgi_group }}"
4747 tags :
48- - install
49- - upgrade-charm
48+ - config-changed
49+ notify :
50+ - Restart wsgi
51+
52+ - name : Write the database settings
53+ template :
54+ src : " templates/database_settings.py.j2"
55+ dest : " {{ application_dir }}/django-project/clickreviewsproject/database_settings.py"
56+ owner : " {{ wsgi_user }}"
57+ group : " {{ wsgi_group }}"
58+ tags :
5059 - db-relation-changed
5160 notify :
5261 - Restart wsgi
62+ when : " 'database' in current_relation"
5363
5464 # XXX Normally our deployment build would ensure these are all available in the tarball.
5565 - name : Install any non-distro dependencies (Don't depend on pip for a real deployment!)
Original file line number Diff line number Diff line change 1+ DATABASES = {
2+ 'default': {
3+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
4+ 'NAME': '{{ current_relation["database"] }}',
5+ 'HOST': '{{ current_relation["host"] }}',
6+ 'USER': '{{ current_relation["user"] }}',
7+ 'PASSWORD': '{{ current_relation["password"] }}',
8+ }
9+ }
Original file line number Diff line number Diff line change @@ -2,29 +2,7 @@ DEBUG = True
22TEMPLATE_DEBUG = DEBUG
33SECRET_KEY = '{{ django_secret_key }}'
44
5- {% if 'db' in relations %}
6- DATABASES = {
7- {% for dbrelation in relations ['db' ] %}
8- {% if loop .first %}
9- {% set services =relations ['db' ][dbrelation ] %}
10- {% for service in services %}
11- {% if service .startswith ('postgres' ) %}
12- {% set dbdetails = services [service ] %}
13- {% if 'database' in dbdetails %}
14- 'default': {
15- 'ENGINE': 'django.db.backends.postgresql_psycopg2',
16- 'NAME': '{{ dbdetails["database"] }}',
17- 'HOST': '{{ dbdetails["host"] }}',
18- 'USER': '{{ dbdetails["user"] }}',
19- 'PASSWORD': '{{ dbdetails["password"] }}',
20- }
21- {% endif %}
22- {% endif %}
23- {% endfor %}
24- {% endif %}
25- {% endfor %}
26- }
27- {% endif %}
5+ from database_settings import DATABASES
286
297TIME_ZONE = 'UTC'
308ROOT_URLCONF = 'clickreviewsproject.urls'
You can’t perform that action at this time.
0 commit comments