Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing django project in LAN systems

Tags:

python

django

lan

I used django and developed a site which is working fine, and its about to move to production and ready for deployment in a couple of weeks.

So before moving to production, i want to share the site with some of my employees to check the functionality and something else. Actually their systems are connected in LAN with mine.

So my system IP address is something like 192.168.12.135, when we run run django development server its runs at localhost:8000, i mean with the system IP address and with a port 8000 like 192.168.12.135:8000 right.

So i had shared them the project site link as 192.168.12.135:8000, but when they tried on the systems which are connected in LAN, it is not accessible and displaying an error Server not found.

I tried the above same way because recently i used python web.py framework and developed a minimal site , and when we run the server, it by default runs as localhost:8080 , and when i accessed this link from others system that are connected in LAN with mine as 192.168.12.135:8000 , its working fine and is accessible.

So can anyone please let me know

1. How to access the site on the systems that are connected in LAN before moving to production(in some real servers like apache, nginx etc.,).

2. Basically i am new to web developing and this is my first site developed in python, so
   i don't know more about servers and deploying a project. So can anyone please let me know   
   the detailed information about deploying django on different servers

(First of all i am looking for a solution for 1st problem(Accessing in LAN before moving to production))

like image 933
Shiva Krishna Bavandla Avatar asked Mar 18 '13 06:03

Shiva Krishna Bavandla


People also ask

How do I run a Django project on a different port?

Inside the commands folder open up the runserver.py script with a text editor. Find the DEFAULT_PORT field. it is equal to 8000 by default. Change it to whatever you like DEFAULT_PORT = "8080"

Can Django be hosted on shared server?

This is one of the options that you can avail to deploy your Django project. The advantage of shared hosting is that it is cheap. The disadvantage is that you might not be able to deploy some advanced projects because you can not install a software on your shared host.


2 Answers

If you run

python manage.py runserver 0.0.0.0:8000

your development server will be available on port 8000 to anyone on your LAN and on localhost as well (and it does not depend on your ip address)

like image 171
Ponytech Avatar answered Sep 18 '22 14:09

Ponytech


You need to explicitly tell the development server to run on your IP rather than localhost.

Try python manage.py runserver your_ip:port.

Though it'll be accessible if you're running through apache or any other webservers other than the development server.

And to your 1st question, I would advice you to host and use a local apache server rather than using development server. Doing so, you can foresee the issues you'll be facing when moving to production.

And to 2nd, there are plenty of resources available configuring Django with different servers. Hail Google. :)

like image 25
Babu Avatar answered Sep 21 '22 14:09

Babu