diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py index c4cd8740512..e2d447147b0 100644 --- a/django/core/management/commands/runserver.py +++ b/django/core/management/commands/runserver.py @@ -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 (?P\d{1,3}(?:\.\d{1,3}){3}) | # IPv4 address (?P\[[a-fA-F0-9:]+\]) | # IPv6 address (?P[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*) # FQDN ):)?(?P\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: