Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da6948f
commit c05deff
Showing
1 changed file
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,10 +1,25 @@ | |||
#!/usr/bin/env python | #!/usr/bin/env python | ||
import os | from os import environ, listdir | ||
from os.path import join, dirname, abspath, exists | |||
import sys | import sys | ||
|
|
||
if __name__ == "__main__": | if __name__ == "__main__": | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") | |||
|
|
||
from django.core.management import execute_from_command_line | # Try to discover project name and set the default settings module | ||
# based on it. If discovery fails, DJANGO_SETTINGS_MODULE environment | |||
# variable must be set. | |||
|
|||
root = dirname(abspath(__file__)) | |||
sys.path.append(root) | |||
settings_module = None | |||
for name in listdir(root): | |||
full_name = join(root, name) | |||
if exists(join(full_name, 'settings', '__init__.py')): | |||
settings_module = name + '.settings' | |||
break | |||
|
|
||
if settings_module is not None: | |||
environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module) | |||
|
|||
from django.core.management import execute_from_command_line | |||
execute_from_command_line(sys.argv) | execute_from_command_line(sys.argv) |