Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#360 closed defect (fixed)

[PATCH] django-admin.py runserver only takes a port when it could also take an ip:port

Reported by: benno@… Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently django-admin.py's runserver command can only take a port number and will always use 127.0.0.1 as the bind address. This patch allows an IP address to be specified by passing <ip address>:<port> instead of just <port>.

Attachments (4)

django-server-addr.diff (2.5 KB) - added by benno@… 10 years ago.
Patch to add ip:port as well as port argument to runserver.
django-server-addr.2.diff (2.7 KB) - added by benno@… 10 years ago.
Fixed version (fixes up empty addr string)
dj360_539.diff (0 bytes) - added by fonso 10 years ago.
Don't explicitly specify the binding address for the server
dj360_539.2.diff (546 bytes) - added by fonso 10 years ago.
Don't explicitly specify the binding address for the server (second try)

Download all attachments as: .zip

Change History (10)

Changed 10 years ago by benno@…

Patch to add ip:port as well as port argument to runserver.

Changed 10 years ago by benno@…

Fixed version (fixes up empty addr string)

comment:1 Changed 10 years ago by adrian

Thanks for this patch.

Before we roll it in, I have a question: What's the use-case for this? Why would somebody need to run the development server (which should NOT be run on a production site) on a separate IP address?

comment:2 Changed 10 years ago by Simon Willison

Here's a use case: you are running the development server on a machine which has a public internet facing IP address and another address that is only visible to your network. You would want the development server to face internally only. This isn't that unlikely in a small development shop where the dev box might double up as the office router.

comment:3 Changed 10 years ago by adrian

  • Status changed from new to assigned

comment:4 Changed 10 years ago by adrian

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [539]) Fixed #360 -- runserver now takes optional 'ip:port' in addition to 'port'. Thanks, benno@…

comment:5 Changed 10 years ago by fonso

In my case, this patch makes the the server refuse remote connections if I don't explicitly indicate the public interface IP. E.g., I have to use:

$ django-admin.py runserver 192.168.1.4:8000

Changing line 550 in core/management.py (http://code.djangoproject.com/file/django/trunk/django/core/management.py?rev=539) to just addr = '' fixes this.

Changed 10 years ago by fonso

Don't explicitly specify the binding address for the server

Changed 10 years ago by fonso

Don't explicitly specify the binding address for the server (second try)

comment:6 Changed 8 years ago by rff_rff@…

another use case: I'm developing on a virtual machine with a minimal installation and connecting from my real one to test. I applied the same change as in dj360_539.2.diff by myself, because it is so much easier to work that way.

Note: See TracTickets for help on using tickets.
Back to Top