Ticket #7735: runserver-ipv6-with-docs-r7920.diff
File runserver-ipv6-with-docs-r7920.diff, 4.5 KB (added by , 16 years ago) |
---|
-
django/core/servers/basehttp.py
658 658 start_response(status, headers.items()) 659 659 return output 660 660 661 def run(addr, port, wsgi_handler ):661 def run(addr, port, wsgi_handler, enable_ipv6=False): 662 662 server_address = (addr, port) 663 httpd = WSGIServer(server_address, WSGIRequestHandler) 663 if not enable_ipv6: 664 httpd = WSGIServer(server_address, WSGIRequestHandler) 665 else: 666 import socket 667 class WSGIServerV6(WSGIServer): 668 address_family = socket.AF_INET6 669 httpd = WSGIServerV6(server_address, WSGIRequestHandler) 664 670 httpd.set_app(wsgi_handler) 665 671 httpd.serve_forever() -
django/core/management/commands/runserver.py
5 5 6 6 class Command(BaseCommand): 7 7 option_list = BaseCommand.option_list + ( 8 make_option('--ipv6', '-6', action='store_true', dest='enable_ipv6', default=False, 9 help='Enables IPv6 support.'), 8 10 make_option('--noreload', action='store_false', dest='use_reloader', default=True, 9 11 help='Tells Django to NOT use the auto-reloader.'), 10 12 make_option('--adminmedia', dest='admin_media_path', default='', … … 20 22 import django 21 23 from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException 22 24 from django.core.handlers.wsgi import WSGIHandler 25 enable_ipv6=options.get('enable_ipv6') 26 if enable_ipv6: 27 import socket 28 if not hasattr(socket, 'AF_INET6'): 29 raise CommandError("This Python does not support IPv6.") 30 23 31 if args: 24 32 raise CommandError('Usage is runserver %s' % self.args) 25 33 if not addrport: … … 27 35 port = '8000' 28 36 else: 29 37 try: 30 addr, port = addrport. split(':')38 addr, port = addrport.rsplit(':',1) 31 39 except ValueError: 32 40 addr, port = '', addrport 33 41 if not addr: 34 addr = '127.0.0.1' 42 if not enable_ipv6: addr = '127.0.0.1' 43 else: addr = '::1' 35 44 36 45 if not port.isdigit(): 37 46 raise CommandError("%r is not a valid port number." % port) … … 51 60 try: 52 61 path = admin_media_path or django.__path__[0] + '/contrib/admin/media' 53 62 handler = AdminMediaHandler(WSGIHandler(), path) 54 run(addr, int(port), handler )63 run(addr, int(port), handler, enable_ipv6=enable_ipv6) 55 64 except WSGIServerException, e: 56 65 # Use helpful error messages instead of ugly tracebacks. 57 66 ERRORS = { -
docs/django-admin.txt
498 498 Note that the default IP address, 127.0.0.1, is not accessible from other 499 499 machines on your network. To make your development server viewable to other 500 500 machines on the network, use its own IP address (e.g. ``192.168.2.1``) or 501 ``0.0.0.0`` .501 ``0.0.0.0`` or ``::`` (with IPv6 enabled). 502 502 503 503 --adminmedia 504 504 ~~~~~~~~~~~~ … … 524 524 525 525 django-admin.py runserver --noreload 526 526 527 --ipv6 528 ~~~~~~ 529 530 Use the ``--ipv6`` option to tell Django to enable IPv6 for the development 531 server. This allows you to specify IPv6 addresses in colon-delimited form and 532 changes the default IP address from 127.0.0.1 to ::1. 533 534 Example usage:: 535 536 django-admin.py runserver --ipv6 537 527 538 Examples of using different ports and addresses 528 539 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 529 540 … … 535 546 536 547 django-admin.py runserver 1.2.3.4:8000 537 548 549 Port 8000 on IPv6 address 2001:0db8:1234:5678::9:: 550 551 django-admin.py runserver --ipv6 2001:0db8:1234:5678::9:8000 552 538 553 Port 7000 on IP address 127.0.0.1:: 539 554 540 555 django-admin.py runserver 7000 … … 543 558 544 559 django-admin.py runserver 1.2.3.4:7000 545 560 561 Port 7000 on IPv6 address 2001:0db8:1234:5678::9:: 562 563 django-admin.py runserver --ipv6 2001:0db8:1234:5678::9:7000 564 546 565 Serving static files with the development server 547 566 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 548 567