Django runserver - page is loading in other PCs - django

I am running a django runserver from my macbook at home. Able to load the page in my mac. But when i tried copy the link and load the page on other PC the page is not loading. Why? Please help..

If both computers are in same network, you can use local IP and the port you indicated with runserver command. For instance, if the computer with django app has an IP of 192.168.1.145, you need to go to http://192.168.1.145:8000 to access your app in other computers with same network.
If it's about accessing the app from different computers with different networks. We have servers for that. If you have to need the app from your own computer, you need to get a static IP.(It's not recommended though.) Call your ISP for static IP.

Related

Running a flask application on a local network with a domain name?

I am doing a side project of transitioning my companies inhouse accounting app to a flask based web site.
I was just testing today to see if I could deploy onto the local network for everyone to access, and that worked will enough however it was my computers local ip ie something like 192.168.1.212:5000.
Is there a way I can run the flask app off my computer and on my computers local network where they could go to something like ourcompanyapp.com and get the app?

Django Application

I have finished coding a Django App. In that app I have created two models in order to record some project information. Also I am showing project locations with markers on a map (OpenStreetMap) by using leaflet.js.
I will use this app only by starting an offline server like "python manage.py runserver". I am using "Firefox" to display the django app.
I really wonder if somehow the information that I keep in my django models or the markers on the OpenStreetMap is somehow reachable by others via on Firefox or leaflet.
Thank you very much in advance.
If you are in the same wi-fi network you can run python manage.py runserver 0.0.0.0:8000 and then your application will be visible for everybody by typing http://your-pc-up:8000
If you want to make it public you have to buy domain (or register free domain) and put it in your vpc / free hosting. There are plenty of tutorial out there which show how to host an application.
This tutorial is really easy and straight forward: http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
You can use ngrok service which gives you domain such as https://c2757c5f.ngrok.io and other users can visit it by accessing this url. In addition, this url can be visited from anywhere!
See more details by visiting here
If you want other users can visit you website from you local server, then you can run manage.py runserver 0.0.0.0:8000. Your app is visible to other users on same network by accessing this http://your-ip:8000/
You could know you ip by using ifconfig command on linux or ubuntu

Chrome not connecting to network

I was wondering how I could let Chrome connect to my network. I am using a website called Codeanywhere.com and I was using a Django container. I used the built-in terminal and installed Python 3.4 and Django 10. I created a project and ran the server, and it said it had created one at this ip: http://127.0.0.1:8000/. However, whenever I try to access it, it the site can't be reached. If it helps, I am using a Chromebook Thinkpad, and it is a school computer. They do block things with Lightspeed Systems and they have a lot of blacklisting things going on. I am trying to learn Django for a project. Below is a screenshot of the screen when I try to access the server.
My screenshot of the error screen.
I can't embed my image yet, I don't have 10 reputation points :/ It's a link instead.
Mistake #1
The server isn't located on your local host, so you need to go to the provided server. for example, when I opened a project I got this instruction:
To access your application over HTTPS, make sure your application is running on port 3000 and use the following link:
https://mysite-{username}551936.codeanyapp.com
Mistake #2
you should run the server with a specified ip commend - and use 0.0.0.0:3000 instead of the usual localhost, like so:
python manage.py runserver 0.0.0.0:3000
In addition, I would reccomend you to read the "mysite Container" file which explains everything about the setup in detail.

How can I view a django site running with 'runserver' remotely

I currently have a django project that I am working on. The project is sitting on my remote webserver, and I start it by running manage.py runserver 0.0.0.0:8000. Howver, if I try to access the site via domainname.com:8000, I can't see the site.
How can I view a django project remotely like this? Do I need to do setup using apache? Punch a hole in the firewall? Is there an easy way?
This is strictly for development purposes.
You need to bind it to an IP, not 0.0.0.0.
Also, you may want to check that firewall rules are not stopping you from accessing port 8000 (I did this this morning!)
You can use ssh tunnels. It's easy to set up in Windows with Putty (look at this example for manageing postgresql) or google how to use tunnels with ssh in Linux. I think this is amazing thing, since I first time get to my databse on remote server :)

How do you debug Django sites using Win 7 XP Mode?

I am developing a Django site using Windows 7 as my dev environment. I have IE6 running through XP mode. Accessing my site through localhost:8000 doesn't work in IE6 (probably since it is still running a VM). Is there a way to access my site in IE6 while it is being served through Django's test server running on Windows 7?
When running the Django runserver on one machine ,but accessing it from another (or Virtual Machine in your case), be sure to:
a) Have the django test server bind to an address that IE6 in the VM can access. To do this, run the server with:
$ python manage.py runserver 192.168.x.x:8000
b) Visit that explicit address and port in IE. For IE6, be sure to specify the 'http' protocol as IE6 doesn't like IP addresses without a protocol:
http://192.168.x.x:8000/
The reason for this is that, inside the VM, localhost or 127.0.0.1 (the defaults for runserver) refer to the virtual machine's IP address space. If using IE6 to test, you want to refer to the host OS, so use an absolute IP address that the client VM can address. There is some documentation on this from the django project, and rest assured this is a common enough need that we all do it - testing multiple variants of IE in a virtual machine seems to be a fact of life :-)
If you are still having troubles, be sure you have determined whether you're using NAT or bridged networking for your client VM as this controls the IP address, OS firewall restrictions (if any), and other avenues for communicating between a VM client and host.
your VM and the server running django are in two separate containers, and you can't access django app using localhost since Django is not installed on the VM. but what you can do is install IE tester http://www.my-debugbar.com/wiki/IETester/HomePage] in windows 7 to test all versions of IE.