Allowed runserver sublcasses to easily override the default port.

This commit is contained in:
Matt Robenolt 2015-05-11 23:24:03 -07:00 committed by Tim Graham
parent 70779d9c1c
commit 0d7a295f28
1 changed files with 4 additions and 2 deletions

View File

@ -16,13 +16,13 @@ from django.db.migrations.executor import MigrationExecutor
from django.utils import autoreload, six
from django.utils.encoding import force_text, get_system_encoding
naiveip_re = re.compile(r"""^(?:
(?P<addr>
(?P<ipv4>\d{1,3}(?:\.\d{1,3}){3}) | # IPv4 address
(?P<ipv6>\[[a-fA-F0-9:]+\]) | # IPv6 address
(?P<fqdn>[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*) # FQDN
):)?(?P<port>\d+)$""", re.X)
DEFAULT_PORT = "8000"
class Command(BaseCommand):
@ -32,6 +32,8 @@ class Command(BaseCommand):
requires_system_checks = False
leave_locale_alone = True
default_port = '8000'
def add_arguments(self, parser):
parser.add_argument('addrport', nargs='?',
help='Optional port number, or ipaddr:port')
@ -68,7 +70,7 @@ class Command(BaseCommand):
self._raw_ipv6 = False
if not options.get('addrport'):
self.addr = ''
self.port = DEFAULT_PORT
self.port = self.default_port
else:
m = re.match(naiveip_re, options['addrport'])
if m is None: