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 runserver”. This just hosts the app at 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, your will have to host the django app at The port number 8000 can be different. To do so, you have to run the command “python runserver”. Now your django app will be hosted on the local area network and can be accessed by others using the address

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. 

But there is also a way in which you can make the django app accessible through all the IP addresses available on the local machine. And this is by using in place of the IP address.

But you should add the domain (IP address) that is going to be used to the ALLOWED_HOSTS list in the file. This process can be automated with a small snippet of code.

Paste this snippet right below the ALLOWED_HOSTS line in the file. And to start the server, execute the command “python runserver” (you can use any other port).

This code snippet will collect all the IP addresses available on the local machine and add them to the ALLOWED_HOSTS list. 

If you want to just host it only on a specific network, you can check out this git repository. Feel free to contribute to it.

Doing this saves time and effort. Also, this is useful if you are planning to use the django app in production.

If you have any questions or suggestions, please share it in the comments below.  

Categories: Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *