Skip to content

Commit

Permalink
Merge pull request #7 from onaio/issue-6
Browse files Browse the repository at this point in the history
Add support for python statements in settings file
  • Loading branch information
moshthepitt authored Oct 15, 2018
2 parents a627044 + 2568544 commit edae42b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ django_settings:
DEFAULT_FROM_EMAIL: "'Hello World <[email protected]>'"
ALLOWED_HOSTS: "[]"
DEBUG: True
## python statements included at the top of settings file
top_python_statements:
- import os
## python statements included at the bottom of settings file
bottom_python_statements:

# wsgi
wsgi_module:
Expand Down
14 changes: 12 additions & 2 deletions templates/local_settings.py.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import os
{% if top_python_statements %}
{% for stmt in top_python_statements %}
{{ stmt }}
{% endfor %}
{% endif %}

{% for k,v in django_settings.items() %}
{{k}} = {{v}}
{% endfor %}
{% endfor %}

{% if bottom_python_statements %}
{% for stmt in bottom_python_statements %}
{{ stmt }}
{% endfor %}
{% endif %}
5 changes: 5 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
- celery
- uwsgi
- 'redis==2.10.6'
top_python_statements:
- import os
- from decimal import Decimal
bottom_python_statements:
- test_var = Decimal(16)
gather_facts: True
become: True
roles:
Expand Down

0 comments on commit edae42b

Please sign in to comment.