I have a django app which I hosted locally on my system, now since other devices are connected and on the same local network as my django app, they too are able to access the website by typing the ipaddress:port of my django app host device.
But I wanted those devices also to access my django app using some domain name, but it's not working. Here is what I tried.
Edited the hosts file on windows and added
127.0.0.1 anythingyoulike.com
127.0.0.1 www.anythingyoulike.com
127.0.0.1. blog.anythingyoulike.com
added our custom domain to the allowed host on our settings.py
ALLOWED_HOSTS = ['www.anythingyoulike.com', 'blog.anythingyoulike.com', 'anythingyoulike.com']
But other devices on my hotspot network are unable to access using these domain names, and only my devices where I hosted my django website is able to access it.
Note : There are Android mobile devices too where I want to access using domain name on my local environment
I think something it's a bit mixed up here. As I see you have appended the desired domain names to the ALLOWED_HOSTS
which is completely correct.
After that you have updated the hosts
file on the server (your laptop). This enables the server to translate the given domain name to the localhost (127.0.0.1)
, so you can access your django app using the domain on the server itself.
The problem is that the clients (android devices in your case) still don't know that they have to translate those domain names into the ip address of the host. In other words you have to update the hosts
files on the clients, not on the server. For that purpose I suggest you to check out the following links:
How to modify the hosts file on your Android device
How to edit 'etc/hosts' file in non-rooted phone
I hope this helped :)