Ticket #14928: 14928-1.diff

File 14928-1.diff, 1.4 KB (added by Claude Paroz, 14 years ago)

Allow FQDN in addr part of runserver

  • django/core/management/commands/runserver.py

    diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
    index b63b57a..e091c82 100644
    a b  
    11from optparse import make_option
    22import os
    3 import re
    43import sys
    54import socket
    65
    from django.core.handlers.wsgi import WSGIHandler  
    98from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException
    109from django.utils import autoreload
    1110
    12 naiveip_re = r'^(?:(?P<addr>\d{1,3}(?:\.\d{1,3}){3}|\[[a-fA-F0-9:]+\]):)?(?P<port>\d+)$'
    1311DEFAULT_PORT = "8000"
    1412
    1513class BaseRunserverCommand(BaseCommand):
    class BaseRunserverCommand(BaseCommand):  
    4139            self.addr = ''
    4240            self.port = DEFAULT_PORT
    4341        else:
    44             m = re.match(naiveip_re, addrport)
    45             if m is None:
    46                 raise CommandError('%r is not a valid port number'
    47                                    'or address:port pair.' % addrport)
    48             self.addr, self.port = m.groups()
     42            try:
     43                self.addr, self.port = addrport.rsplit(':', 1)
     44            except ValueError:
     45                self.addr, self.port = '', addrport
    4946            if not self.port.isdigit():
    5047                raise CommandError("%r is not a valid port number." % self.port)
    5148            if self.addr:
Back to Top