Django Runserver - moving from running locally - python

I want to move from local host to a static IP address (I have it already) with specific DNS name, I'm confused on how to do that? and how to make my app working just by accessing this IP or DNS names from a web browser? Should any machine install all the requirements like Python, Django, IDE etc? not sure how this will happen. I appreciate the help
Edit: I tried this:
runserver 0.0.0.0:80
from the manage.py, that should allow any IP to access my page, however, is that the good way to do it?? Also, how to specify the DNS, and I want a domain name instead of an IP to access the page.

I'm fairly new to Django but I got my website up and running on PythonAnywhere. It was easy to setup and they provide domain name as [username].pythonanywhere.com. I followed this tutorial in order to set it up: http://tutorial.djangogirls.org/en/deploy/
The tutorial does it by putting the code up on Github then going to PythonAnywhere and doing a git clone. However, PythonAnywhere allows you to upload your code directly to their servers. After you upload the code you can use a virtual command prompt to pip install the packages you need, such as Django.
I hope this helps. Let me know if you have any questions.

Related

Running Django in IIS

I have a Python application that's that has been working correctly as backend for my website, up to now I have been running it using "python manage.py runserver IP:8000" in CMD. However I would like it to start using HTTPS, but when I try to access through my browser on https://IP:PORT I get the following error:
You're accessing the development server over HTTPS, but it only
supports HTTP.
The server I am running all of this is a Windows Center 2019 DataCenter, normally on a linux environment I would just use NGINX+GUNICORN.
I was browsing possible solutions and stumbled upon this, however I already am using IIS to host a website (My frontend), so I needed to figure out how to host several websites for the same IP, I have now found this.
Long story short, I configured the new IIS website for it to access my django, I then changed the hostname since both frontend and the new backend will using the same ip and ports (80, 443).
But now I have hit a spot where I'm confused due to my lack of experience in IIS and networking. I can't seem to understand how the request will go through to my Python-Django APP.
Something important to mention on how I access the Django APP in the past.
Lets say my front end is https://pr.app.com, whenever any request needed to be made to the backend. I would ask for said information in http://pr.app.com:8000/APIService/..../
This is how the binding for my frontend looks like
And this is the binding for the new backend where I changed the hostname as the second guide linked said
Any guidance or help would be most appreciated,
Thanks in advance
*Update
So I tried pausing my frontend website and used these bindings on the new backend website, I was able to get a screen of Django meaning it seems to be working or at least communicating.
Now I would need to have the hostname of the backend (pr.abcapi.com) somehow refer or redirect to the hostname of the frontend (pr.abc.com).
How could I achieve this?

How to deploy django website in ubuntu 18.04 + plesk + apache in digitalocean droplet

In my droplet is running several PHP websites, recently I tried to deploy a Django website that I build. But it's doesn't work properly.
I will explain the step that I did.
1, Pointed a Domain name to my droplet.
2, Added Domain name using Plesk Add Domain Option.
3, Uploaded the Django files to httpdocs by Plesk file manager.
4, Connected the server through ssh and type python manage.py runserver
0:8000
5, My Django Website is successfully running.
Here are the real issues occurs, We need to type exact port number to view the website every time. Eg:- **xyz.com:8000 **
As well as the Django webserver is down after sometimes.
I am newbie to Django all I have experience in deploying a PHP website. If my procedure is wrong please guide me to correct procedure.
Thanks in Advance.
Django Runserver is not a production one, it should be used only for development. That's why you need to explicitly type in the port and it sometimes go down because of code reload or other triggers.
Check Gunicorn for example, as a production server for Django applications. (there are other options also)
I suggest following this guide. Covers initial setup of django with gunicorn and nginx which is essential for deployment, you don't have to add the port to access the site. It doesn't cover how to add the domain but it seems you already know how to add the domain though.

How to deploy codenode

Aloha everyone,
So I was hoping to deploy codenode 'http://codenode.org/', on my website nested within a page. For the life of me I just can't follow the documentation and figure out what I'm supposed to do.
It only ever seems to talk about running things locally from the terminal, how are you supposed to set it up with regards to views, models and templates?
Thanks in advance.
They're simply telling you to install it via pip and virtualenv. This isn't terribly difficult to do on a host that is very Django and Python friendly, such as WebFaction. You can always put the necessary files where they need to go so that they will be added to your Python path via FTP, etc.

How to use scripts to excecute django commands

Hi recently created my website in django. And I have used a web hosting provider who has django, python and my sql installed. But they do not have the ssh option or command prompt in their file manager. How can I use a script to excecute all the commands after uploading my site to the server .
I want file to be created like this updatedb.sh or updatedb.py .
Can anyone tell me how to use the scripts alone to host my django site live.
It is possible to have your Django views execute lines like:
import os
os.system("python manage.py syncdb")
In theory you could get the site working like that. However, this is a very poor strategy for deployment. Aside from the hassle of having os.system lines every time you want to do anything, what will you do if your entire site breaks? You'd be using convoluted hacks just to do the most basic maintenance.
If your web hosting provider truly doesn't support any kind of command line or even give you other options for setting up Django, it's time to find a new web hosting provider. I might recommend heroku, which supports Django and lets you deploy using git. (It is also free up to a certain amount of use).

google code + temp server?

We are starting a new project to develop a website using django. We have created a project on google code. We would like to be able to occasionally show the progress of the site to some people, without having to purchase a real server.
We are all modifying the project through eclipse and SVN. What's the best way to create a runserver type thing but allow othes to access over the internet temporarily?
thanks
One way is to run Django development server to bind on multiple interfaces:
python manage.py runserver 0.0.0.0:8000
Or specify a IP of the interface to bind to, for example this would only listen on the interface who's IP is 192.168.1.100:
python manage.py runserver 192.168.1.100:8000
But Django development server is single threaded and thus will not work good with concurrent requests.
I would advise setting up a development preview on shared hosting or something, or even locally, with a proper web server (such as Apache or ngnix).
If you do it locally just portforward your traffic from router to your local installation, if you don't have static IP you can use a service such as DynDns or No-ip.
This subject has been covered several times on Stackoverflow, feel free to search for other ideas.

Categories