-
Notifications
You must be signed in to change notification settings - Fork 14
/
manage.py
executable file
·29 lines (23 loc) · 1.03 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
# Python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_project.settings')
import django
django.setup()
# Use the runserver addr/port defined in settings.
from django.conf import settings
default_addr = getattr(settings, 'RUNSERVER_DEFAULT_ADDR', '127.0.0.1')
default_port = getattr(settings, 'RUNSERVER_DEFAULT_PORT', 8000)
from django.core.management.commands import runserver as core_runserver
original_handle = core_runserver.Command.handle
def handle(self, *args, **options):
if not options.get('addrport'):
options['addrport'] = '%s:%d' % (default_addr, int(default_port))
elif options.get('addrport').isdigit():
options['addrport'] = '%s:%d' % (default_addr, int(options['addrport']))
return original_handle(self, *args, **options)
core_runserver.Command.handle = handle
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)