So I finished making a simple django app. All it is, is a website which has a /admin page, where someone can sign into and create posts which update to the site. Basically like a blog. I could've done it with WordPress but I prefer django a lot more. My last question is, how do I know host the django app as a website? I don't want a step by step guide, I know this site isn't meant for it but can someone give me a textbook or a link to something which shows how to do it? Because really I tried looking and couldn't find anything. The app isn't for me, it's for an organization and I don't know if their site is going to be .com, .net etc. And I don't know what they will be hosting the site on but I really don't want to end up having to redo everything with WordPress in order to just host the site.
You could host your app on Amazon EC2. If you Google Django + EC2, you will see lots of tutorials.
you can host use OPENSHIFT.
Create an account at http://openshift.redhat.com/
Install the RHC client tools if you have not already done so:
sudo gem install rhc
Create a python-2.6 application
rhc app create -a django -t python-2.6
Add this upstream repo
cd django
git remote add upstream -m master git://github.com/openshift/django-example.git
git pull -s recursive -X theirs upstream master
Then push the repo upstream
git push
Here, the admin user name and password will be displayed, so pay
special attention.
That's it. You can now checkout your application at:
http://django-$yournamespace.rhcloud.com
now the difficult part
you want to edit the files in folder django/wsgi/openshift
mostly you want to edit the settings.py and copy your project folder to this folder.
now check it in localhost ie python manage.py runserver. if it worked successfully you can call git push that is it.
https://www.heroku.com/ is awesome web-hosting with django support and totally simplified deployment process. Tutorial included.
Related
I am new to git and Pythonanywhere. So, I have a live Django website which is hosted with the help of Pythonanywhere. I have made some improvements to it. I have committed and pushed that changes to my Github repository. But, now I don't know that how to further push that changes to my Pythonanywhere website. I am so confused. Please help!!! Forgive me, I am new to it.
You need to go to the repo on PythonAnywhere in a bash console, run git pull (You may need to run ./mange.py migrate if you made changes to your models) and then reload the app on "Web" configuration page on PythonAnywhere. .
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.
My web host does not have python and I am trying to build a machine learning application. I know that heroku lets you use python. I was wondering if I could use heroku as a python server? As in I would let heroku do all of the python processing for me and use my regular domain for everything else.
Yes, and it may be a pain at first but once it is set I would say Heroku is the easiest platform to continually deploy to. However, it is not intuitive - don't try and just 'take a stab' at it; follow a tutorial and try and understand why Heroku works the way it does.
Following the docs is a good bet; Heroku has great documentation for the most part.
Here's the generalized workflow for deploying to Heroku:
Locally, create your project and use virtualenv to install/manage
libraries.
Initialize a git repository in the base dir for your
Python project; create a heroku remote (heroku create)
Create a
procfile for Heroku to use when starting gunicorn (or see
the options for using waitress/etc); this is used by Heroku to start your process
cd to your base dir; freeze
your virtualenv (pip freeze > requirements.txt) and add/commit
requirements.txt. This tells Heroku what packages need to be installed, a requirement for your deployment to work. If you are trying to run a Python project and there are required packages missing, the app will be unable to start and Heroku will display an Internal Server Error.
Whenever changes are made, git commit your changes and git push heroku master to push all commits to Heroku. This will cause Heroku to restart the server application with your updated deployment. If there's a failure, you can use heroku rollback to just return to your last deployment.
In reality, it's not a pain in the ass, just particular. Knowing the rules of Heroku, you are able to manage your deployment with command-line git commands with ease.
One caveat - If deploying Django, Flask applications etc there are peculiarities to account for; specifically, non-project files (including assets) should NOT be stored on Heroku as Heroku periodically restarts your 'dyno' (server instance(s)), loading the whole project from the latest push to Heroku. With Django and Flask, this typically means serving assets/static/media files from an Amazon S3 bucket.
That being said, if you use virtualenv properly, provision your databases, and follow Heroku practices for serving files and commiting updates, it is (imho) the absolute best platform out there for ease of use, reliable uptime, and well-oiled rolling deployments.
One last tip - if you are creating a Django app, I'd suggest starting your project out of this boilerplate. I have a custom one I use for new projects and can start and publish a project in minutes.
Yes, you can use Heroku as a python server. I put a Python Flask server on Heroku but it was a pain: Heroku seemed to have some difficulties, and there were lots of conflicting advice on getting around those. I eventually got it working, can't remember what web page had the ultimate answer but you might look at this one: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xviii-deployment-on-the-heroku-cloud
Have you done your Python Server on Heroku by using twisted?
I don't know if this can help you.
I see the doc 'Getting Started on Heroku with Python' is about the Django.
It is sure that Heroku can use Twisted from docs
Pure Python applications, such as headless processes and evented web frameworks like Twisted, are fully supported.
django-twisted-server has twisted in django but it isn't on Heroku.
I work with Openshift and in specific with Python. I have done many projects in there and I think the most irretating thing is that when you deploy your application, the server is down and you cannot even show a custom message.
I was socked after months when I searched in Google that there is an option to Hot Deploy an application. To git push it without the server get down. I am not a computer scientist, so I cannot understand if this technique has any drawbacks on my application.
Also, until now, when I wanted to update my application, I was doing:
git add .
git commit -a -m 'mycommit'
git push
I read on the manual that I have to enable the Hot Deployment with creating a file on the directory:
C:\app_directory> copy NUL > .openshift\markers\hot_deploy
But after that, how will I (hot) deploy the changes in my server?
Thank you
Once you have added the hot_deploy marker to your git repository, you need to follow the same git add, git commit, git push procedure, the only difference will be that your site will not shut down while it is being deployed. The new code will be deployed and everything should work as expected.
You need to add the marker file to your Git to make the change through to the the server.
git add .openshift/markers/hot_deploy
git commit -m "Changing application to hot deploy"
After this your subsequent commits (using the git add/commit/push combination) will not restart your server.
Alternatively you can use the following rhc commands to enable and disable auto-deployment.
rhc app-configure <app> auto-deploy
rhc app-configure <app> no-auto-deploy
Hi heroku python people,
I want my heroku app to access shared private libraries in my github account.
So I would like to have a requirements.txt file that looks like this ...
# requirements.txt
requests==1.2.2
-e git+ssh://git#github.com/jtushman/dict_digger.git#egg=dict_digger
And I would like it to use a ssh key that I upload with heroku keys:add or have some mechanism to get a private key from the heroku cli.
Right now I get the following error (which is I guess expected):
Host key verification failed.
It does work if I do (per #kenneth_reitz's https://stackoverflow.com/a/9136665/192791):
-e git+https://username:password#github.com/jtushman/dict_digger.git#egg=dict_digger
But it is really unworkable for me to put credentials in my requirements.txt file
Has anyone come up with a nice solution for this?
I have also posted an issue on the heroku python buildpack project here
Kenneth, the maintainer of heroku's python buildpack said the following (and I am cutting and pasting here)
I would currently recommend the way mentioned (git over https)
Using the key you have registered with heroku would be cool, but
unfortunately, you would have to provide your private key for this to
work. Quite undesirable.
However, you could also write your keys into a .ssh folder in your app
or use .profile scripts to facilitate this.
Can see the full thread here: https://github.com/heroku/heroku-buildpack-python/issues/97
I had the same issue before I wanted to use django-avatar and the version in PyPI is old and doesn't support Django 1.5 Custom User .
The simple solution is to download the package and use it as a regular app as if it was part of your project then just git add . and push it and it works !
It might not be the best idea but it just works .