Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5376 -- Added --addrport option to the 'testserver' command. T…

…hanks, toddobryan

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6204 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fe78237a220ad841d806dd9ee53961e7c1d3c7b2 1 parent 725716b
Adrian Holovaty authored September 14, 2007
6  django/core/management/commands/testserver.py
@@ -7,6 +7,9 @@ class Command(BaseCommand):
7 7
         make_option('--verbosity', action='store', dest='verbosity', default='1',
8 8
             type='choice', choices=['0', '1', '2'],
9 9
             help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
  10
+        make_option('--addrport', action='store', dest='addrport', 
  11
+            type='string', default='',
  12
+            help='port number or ipaddr:port to run the server on'),
10 13
     )
11 14
     help = 'Runs a development server with data from the given fixture(s).'
12 15
     args = '[fixture ...]'
@@ -19,6 +22,7 @@ def handle(self, *fixture_labels, **options):
19 22
         from django.test.utils import create_test_db
20 23
 
21 24
         verbosity = int(options.get('verbosity', 1))
  25
+        addrport = options.get('addrport')
22 26
 
23 27
         # Create a test database.
24 28
         db_name = create_test_db(verbosity=verbosity)
@@ -30,4 +34,4 @@ def handle(self, *fixture_labels, **options):
30 34
         # a strange error -- it causes this handle() method to be called
31 35
         # multiple times.
32 36
         shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name
33  
-        call_command('runserver', shutdown_message=shutdown_message, use_reloader=False)
  37
+        call_command('runserver', addrport=addrport, shutdown_message=shutdown_message, use_reloader=False)
30  docs/django-admin.txt
@@ -627,14 +627,34 @@ This is useful in a number of ways:
627 627
       in any way, knowing that whatever data changes you're making are only
628 628
       being made to a test database.
629 629
 
630  
-Note that this server can only run on the default port on localhost; it does
631  
-not yet accept a ``host`` or ``port`` parameter.
632  
-
633  
-Also note that it does *not* automatically detect changes to your Python source
634  
-code (as ``runserver`` does). It does, however, detect changes to templates.
  630
+Note that this server does *not* automatically detect changes to your Python
  631
+source code (as ``runserver`` does). It does, however, detect changes to
  632
+templates.
635 633
 
636 634
 .. _unit tests: ../testing/
637 635
 
  636
+--addrport [port number or ipaddr:port]
  637
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638
+
  639
+Use ``--addrport`` to specify a different port, or IP address and port, from
  640
+the default of 127.0.0.1:8000. This value follows exactly the same format and
  641
+serves exactly the same function as the argument to the ``runserver`` subcommand.
  642
+
  643
+Examples:
  644
+
  645
+To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
  646
+
  647
+    django-admin.py testserver --addrport 7000 fixture1 fixture2
  648
+    django-admin.py testserver fixture1 fixture2 --addrport 8080
  649
+
  650
+(The above statements are equivalent. We include both of them to demonstrate
  651
+that it doesn't matter whether the options come before or after the
  652
+``testserver`` command.)
  653
+
  654
+To run on 1.2.3.4:7000 with a `test` fixture::
  655
+
  656
+    django-admin.py testserver --addrport 1.2.3.4:7000 test
  657
+
638 658
 --verbosity
639 659
 ~~~~~~~~~~~
640 660
 

0 notes on commit fe78237

Please sign in to comment.
Something went wrong with that request. Please try again.