I am developing a web application on my local computer in Django.
Now I want my webapp to be accessible to other computers on my network. We have a common network drive "F:/". Should I place my files on this drive or can I just write something like "python manage.py runserver test_my_app:8000" in the command prompt to let other computers in the network access the web server by writing "test_my_app:8000" in the browser address field? Do I have to open any ports and how can I do this?
To connect to Django from a different machine, you must open port 80, 443 for remote access. Refer to the FAQ for more information on this. IMPORTANT: Making this application's network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks.
It is should be done with central system or server.
By default manage.py runserver
will not give ip bind permission. So
Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).
If you want to check in your local machine then follow
python manage.py runserver 0.0.0.0:8000
Now go to your network computer and access your ip like 192.168.1.24:8000
Updated:
For Django version about 1.10 you should add your host to ALLOWED_HOSTS here
Just add your own IP Address to ALLOWED_HOSTS
ALLOWED_HOSTS = ['192.168.1.50', '127.0.0.1', 'localhost']
and run your server python manage.py runserver 192.168.1.50:8000
and access your own server to other computer in your network
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With