简体   繁体   中英

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.

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

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 xxxx is the ip and 8080 is the port.

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

For more details read this document

from the django official documentation.

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

"DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that's how it's gonna stay. We're in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)"

I have tried hosting on django development server, later noticed that the server goes down frequently. Its better to use servers like apache for production.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM