Hosting a Django project locally

So I am trying to locally host a Django project that I am working on.

I am looking to be able to access all computers connected to the local network to this django / webapp. Kind of like a central, internal, local only website / hub. And I was wondering how I can set up my project to do this.

Do I need to configure a web server to perform this function? If you could recommend someone? Can I do this in Django itself using the dev server? Any help would be greatly appreciated.

Thank you for your time.

+3


source to share


3 answers


We can say that it can be done. While you are running django project pass the server IP and port (unless you are using the default port)

python manage.py runserver x.x.x.x:8080

      

where x.x.x.x

is ip and 8080

is port.



Now you need to type x.x.x.x:8080

in the browser on the device connected to the network.

Read more read this document

+7


source


I will try to answer this as far as I know. I have two Django apps (separate projects) that are only accessible via LAN or as, as you said, central, internal, local only website / hub. My company uses it for different applications. You don't need a web server, because Django does all of this. About setting up your project, you can use your PC as a local server, but if you think there will be a lot of traffic, you need a fairly powerful machine (I mean a dedicated dedicated PC with better specs) that can handle all the traffic (we are at in fact use the same PC to run Django apps to make it possible). For installation guide visit here , and for more details visithere and here .

You can run a server python manage.py runserver

that only runs on your computer, which you can use when developing the application (no one can access it, although you will be connected to the internet or local network)

You can also start the server python manage.py runserver your ip address:port number

. eg.python manage.py runserver 192.168.12.1:8000

Now that you have two projects running on the same computer (as in my case) you need to keep the ip the same, but just change the port number. An example is as shown below.



for the first Django server

python manage.py runserver 192.168.12.1:8000

for the second Django server

python manage.py runserver 192.168.12.1:1234

+6


source


from the official django documentation.

https://docs.djangoproject.com/en/1.11/ref/django-admin/

"DO NOT USE THIS SERVER IN YOUR PRODUCTION SETUP. It has not passed security audits or performance tests (and this is how it will work). In order to build web frameworks, not web servers, to be able to handle a production environment, it is outside the scope of Django .) "

I tried hosting on django development server, later noticed that the server goes down a lot. Better to use servers like apache for production.

0


source







All Articles