Skip to content

Commit

Permalink
Handle new app-loading mechanism for Django 1.7 in fabfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerivas committed Mar 5, 2015
1 parent 6830a7b commit 2ae160f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mezzanine/project_template/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,15 @@ def python(code, show=True):
"""
Runs Python code in the project's virtual environment, with Django loaded.
"""
setup = "import os; os.environ[\'DJANGO_SETTINGS_MODULE\']=\'settings\';"
# Handle environment variable and special case for Django >= 1.7
setup = "import os; os.environ[\'DJANGO_SETTINGS_MODULE\']=\'settings\';" \
"import django;" \
"django.setup() if django.VERSION[1] >= 7 else None;"
full_code = 'python -c "%s%s"' % (setup, code.replace("`", "\\\`"))
with project():
result = run(full_code, show=False)
if show:
print_command(code)
result = run(full_code, show=False)
return result


Expand Down

0 comments on commit 2ae160f

Please sign in to comment.