问题
Hi everyone i'm trying to learn the django framework and I'm using PyDev (Eclipse Python Development Framework/Plugin). When I try to run my application I get an error:
Error: [Errno 10013]
I know that this is because of the port. I use the port 8000 and i want to change it to 8080. Does anyone knows what exactly should i do to change the port?
pydev debugger: starting
Validating models...
0 errors found
Django version 1.3.1, using settings 'muapp.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Error: [Errno 10013]
It might be useful to point out that PyDev, like Eclipse, runs the configured command when the Run
button is pressed. How is the default command and/or its options changed?
回答1:
Have a look at this video tutorial. Skip about 14 minutes in. Then use runserver 8080 instead of runserver in the arguments.
回答2:
Please take a look at the PyDev Documentation on how to change the Run configuration.
Run/Debug as Django
Run as Django/Debug as Django are available (note that they set the --noreload by default).
This will create a default Run configuration, so, you may edit it later through run > run configurations (or debug > debug configurations) if you want to change a parameter.
Note: to know how to rerun the last launch see: the Rerun Last Launch topic on PyDev Launching
Note 2: if the --noreload is not passed, only the parent process will be killed from Eclipse and the others will only be killed when they'd be reloaded (i.e.: on a code-change).
Whether it's "Eclipse" or "PyDev", right-click on the Project and select "Run As" --> "Run Configurations..."
Additionally, according to the django Documentation,
runserver [addrport]¶
Starts a lightweight development Web server on the local machine. By default, the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an IP address and port number explicitly.
Therefore, in your Project's Run Configuration, on the Arguments tab, simply add:
runserver 0.0.0.0:8080
This should have the server listen on all interfaces/IPs. Alternatively, you can make it more specific to your public-facing IP instead:
runserver 123.456.789.123:45678
Please, note that in this case, my IP would be "123.456.789.123" and the port would be "45678".
The following Answers might also be of use:
How to make Django's devserver public ? Is it generaly possible?
How can i get the running server URL
External Link; Third-party blog-post
来源:https://stackoverflow.com/questions/8826768/change-port-in-pydev