Last active
August 15, 2016 11:48
-
-
Save alexryabtsev/0108201a41cf39e705ea22c79a3d9a8a to your computer and use it in GitHub Desktop.
Django management commands hook for PyInstaller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import inspect | |
| import os | |
| import sys | |
| import django.core.management | |
| import django.utils.autoreload | |
| PROJECT_PATH = os.path.realpath(os.path.dirname(inspect.getfile(inspect.currentframe()))) | |
| sys.path.append(os.path.join(PROJECT_PATH, 'apps'),) | |
| def _get_commands(): | |
| commands = { | |
| 'clearsessions': 'django.contrib.sessions', | |
| 'set_admin_password': 'profiles', | |
| } | |
| return commands | |
| _old_restart_with_reloader = django.utils.autoreload.restart_with_reloader | |
| def _restart_with_reloader(*args): | |
| a0 = sys.argv.pop(0) | |
| try: | |
| return _old_restart_with_reloader(*args) | |
| finally: | |
| sys.argv.insert(0, a0) | |
| django.core.management.get_commands = _get_commands | |
| django.utils.autoreload.restart_with_reloader = _restart_with_reloader |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment