Home > Back-end >  external network for django Webpage
external network for django Webpage

Time:07-21

I have a project in Django and it is running on my local machine, I got to make the setting by putting: Allowedhosts = ["*"] and python manage.py runserver 0.0.0.0:8000 This is enough so that I can access the page through another machine on the same network, but I would like to know a way to make access available through an external network, the question is, how do I do it ??

CodePudding user response:

You need to expose your machine to the external network you are trying to access from through your router.

Be aware that with this code you will be exposing the 8000 port and everyone in that network could be able to access your site. To limit who can access, you can add the incoming IP to the ALLOWED_HOSTS variable like this:

ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'EXTERNAL_IP']

Check reference at: https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts

  • Related