Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locally hosting Django project

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

I'm looking to have the ability to have all computers who are connected to the local network be able to access this django app/webapp. Sort of like a central, internal, local only website/hub. And I was wondering how I could go about setting up my project to be able to do this.

Would I need to setup a webserver to accomplish this functionality? If so would you be able to recommend any? Can I do this within Django itself using the dev server? Any help would be greatly appreciated.

Thank you for your time.

like image 923
FunkyFresh Avatar asked Oct 11 '14 05:10

FunkyFresh


People also ask

How would we run your project to a local network Django?

Of course it can be done. When you run the django project, pass on the server ip address and port (if you are not using the default port). Where x.x.x.x is the ip and 8080 is the port. Now all you need is to enter x.x.x.x:8080 in browser on the network connected device.


2 Answers

Of course it can be done. When you run the django project, pass on the server ip address and port (if you are not using the default port).

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

Where x.x.x.x is the ip and 8080 is the port.

Now all you need is to enter x.x.x.x:8080 in browser on the network connected device.

For more details read this document

like image 75
nu11p01n73R Avatar answered Oct 07 '22 18:10

nu11p01n73R


I'll try answering to this to the best of my knowledge. I have two Django apps(separate projects) which is accessible only through LAN or like as you said central,internal,local only website/hub. My company uses it for different applications. You don't need any webserver because the Django does it all. About setting up your project you can use your PC as local server but if you think traffic is gonna be much then you need a fairly powerful machine (I mean to say dedicated separate PC with better specs) which can handle all the traffic (We actually use same PC for running both the Django apps so its possible). For installation guide visit here and for more clear information visit here and here.

You can run server by python manage.py runserver which runs only on your machine which you can use while developing the app (none can access it though you will be connected to internet or LAN)

You can also run server by python manage.py runserver your ip address:port number. eg. python manage.py runserver 192.168.12.1:8000

Now when you have two projects running in same machine (as in my case) you need to keep the ip same but just change the port number. Example is as shown below.

for first Django server

python manage.py runserver 192.168.12.1:8000

for second Django server

python manage.py runserver 192.168.12.1:1234

like image 45
d-coder Avatar answered Oct 07 '22 18:10

d-coder