lambdalisue /
django-inspectional-registration
| 1 | # -*- coding: utf-8 -*- |
||
| 2 | from __future__ import unicode_literals |
||
| 3 | """ |
||
| 4 | Django 1.2 - 1.6 compatible manage.py |
||
| 5 | Modify this script to make your own manage.py |
||
| 6 | """ |
||
| 7 | __author__ = 'Alisue <[email protected]>' |
||
| 8 | import os |
||
| 9 | import sys |
||
| 10 | |||
| 11 | |||
| 12 | if __name__ == '__main__': |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 13 | # add extra sys.path |
||
| 14 | root = os.path.abspath(os.path.dirname(__file__)) |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 15 | extra_paths = (root, os.path.join(root, 'src')) |
||
| 16 | for extra_path in extra_paths: |
||
| 17 | if extra_path in sys.path: |
||
| 18 | sys.path.remove(extra_path) |
||
| 19 | sys.path.insert(0, extra_path) |
||
| 20 | # set DJANGO_SETTINGS_MODULE |
||
| 21 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings') |
||
| 22 | |||
| 23 | try: |
||
| 24 | # django 1.4 and above |
||
| 25 | # https://docs.djangoproject.com/en/1.4/releases/1.4/ |
||
| 26 | from django.core.management import execute_from_command_line |
||
| 27 | execute_from_command_line(sys.argv) |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 28 | except ImportError: |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 29 | # check django version |
||
| 30 | import django |
||
| 31 | if django.VERSION[:2] >= (1.4): |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 32 | # there are real problems on importing |
||
| 33 | raise |
||
| 34 | from django.core.management import execute_manager |
||
| 35 | settings = __import__(os.environ['DJANGO_SETTINGS_MODULE']) |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 36 | execute_manager(settings) |
||
| 37 |