How to serve a django app on a local area network
In this post, I will show you how I automated the process of hosting a django app on a local area network. The usual way to host a django app locally is by running “python manage.py runserver”. This just hosts the app at 127.0.0.1:8000. Now, this app cannot be accessed by others on your network. In order for other devices to access your app, you will have to host the app with the IP address that your computer has on the network. For example, if your IP address is 192.168.1.3, your will have to host the django app at 192.168.1.3:8000. The port number 8000 can be different. To do so, you have to run the command “python manage.py runserver 192.168.1.3:8000”. Now your django app will be hosted on the local area network and can be accessed by others using the address http://192.168.1.3:8000/. To get you IP address, you can run the command “ifconfig” on the shell and find out (or “ipconfig” for windows). And then you copy and paste the IP address in the command. ...
