The logo I made for http://answermethis.pythonanywhere.com
seen from Sweden

seen from Malaysia

seen from Portugal

seen from United Kingdom

seen from Yemen
seen from United States

seen from United States
seen from Germany

seen from China

seen from United Kingdom

seen from Malaysia
seen from Sweden
seen from Italy

seen from Estonia
seen from Canada
seen from Sweden

seen from United States

seen from United States

seen from South Africa

seen from United States
The logo I made for http://answermethis.pythonanywhere.com
#DjangoGirls #DjangoGirlsCo #AlmostDone #Python #LalitasBlog #GitHub #PythonAnywhere #TallerDeProgramación #Django #Phyton #Bucaramanga #working on #programming #algorithm #thinking #Saturday #teacher #teachers #teacherlife #Code #iCode #Colombia
Python/Django - An easy free way to host your django applications.
I have recently been looking for places to host my django application, and found pythonanywhere to be the easiest of the lot.
This post is targeted for Django 1.54 and python 2.7, but with slight changes can be made to work with other versions aswell.
Some of the other options are
Heroku
Openshift
Aws
So to host a django app to pythonanywhere,first signup for a beginner pythonanywhere account.
https://www.pythonanywhere.com/pricing/
Since it is a beginner account, i believe you will not be let to choose your own domain name. It is generally of the format http://<username>.pythonanywhere.com, where username will be your username.Once you are done with this you will have a similar looking dashboard.
Now that you have python anywhere account setup its time to push ur project to pythonanywhere server. The easier way to do is to clone your project from github to their server.
For this create a repo in github/bitbucket or any such vc service, and push your project to github(i would be doing it with github) if you have not done that already. Make sure you use virtualenv for your projects as it makes it convenient to have all ur requirements in one contained environment and easy to replicate a similar structure in the server. Also have a requirement.txt file listing all the packages required, in you project root folder.
Once you have got this part, go to your pythonanywhere dashboard shown above in the pic and under console tab click the bash option to open a terminal.
Create a virtualenv and clone your github project repo:
In the terminal :
mkvirtualenv <your_virtualenv_name> --python=/usr/bin/python2.7
<your_virtualenv_name> : name of your virtualenv
--python=/usr/bin/python2.7: make sure you use the right version of python for you project.
Activate your virtualenv with the command: workon <your_virtualenv_name>
eg: say your virtualenv is name myvirtualenv, then it would be:
workon myvirtualenv
once you got the virtualenv activated , clone your github repo to the server.
git clone <url_of_your_git_hub_repo>
Now install all the required packages using the requiremnts.txt file:
pip install -r requirements.txt
with this your get to your project folder which contains manage.py file and setup your database.
python manage.py syncdb
Setting up your wsgi script:
From your pythonanywhere dashboard click the Web tab and click on the create a new app tab. A popup box will then appear. Follow the instructions on-screen, and when the time comes, select the manual configuration option and complete the wizard.
To configure the wsgi script , click the wsgi configuration file link present on the code section.
this will take you wsgi script file with line of commented out codes for each framework. Under the django section of it:
either uncomment and replace accordingly or just copy paste the following piece code.
# TURN ON THE VIRTUAL ENVIRONMENT FOR YOUR APPLICATION activate_this = '/home/<username>/.virtualenvs/<name_of_your_virtualenv>/bin/activate_this.py'execfile(activate_this, dict(__file__=activate_this))import osimport sys# ADD YOUR PROJECT TO THE PYTHONPATH FOR THE PYTHON INSTANCEpath = '/home/<username>/<your_project_folder>' if path not in sys.path: sys.path.append(path) os.chdir(path) # TELL DJANGO WHERE YOUR SETTINGS MODULE IS LOCATED os.environ['DJANGO_SETTINGS_MODULE'] = '<your_project_folder_which_contains_setting_file>.settings' # IMPORT THE DJANGO WSGI HANDLER TO TAKE CARE OF REQUESTS import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
replace,
<username>, - with your python anywhere username.
<name_of_your_virtualenv>: - with your virtualenv name
<your_project_folder> : - with the path till your root folder
<your_project_folder_which_contains_settings_file> : - the project folder which contains the settings file of your project.
With this you have completed setting up wsgi script, save it and hit the reload server button.
Setting up the static paths and virtualenv path:
The last step is to setup the static path and your virtualenv path in your web console.
click on the enterpath link and enter the path of your virtualenv folder.
similarly we need to link the static folder path as well ,
Underneath the Static files header, perform the following.
Click Enter URL and enter /static/admin, followed by return.
Click the corresponding Enter path text. Set this to /home/<username>/.virtualenvs/<your_virtualenv_name>/lib/python2.7/site-packages/django/contrib/admin/static/admin, where <username> should be replaced with your PythonAnywhere username. Remember to hit return to confirm the path.
Repeat the two steps above for the URL /static/ and path /home/<username>/tango_with_django/tango_with_django_project/static, with the path setting pointing to the static directory of your web application.
Save the change to and hit reload the application.With these settings , i believe you should have successfully deployed your application.
Hit the llink to your appliction, which will mostly be, http://<username>.pythonanywhere.com. and you would be able to see your app up and running. cheers!
Kindly let me know if you have any problems following this post and i would
be more than happy to help you out.This is my first blog post, so any feedbacks would be highly helpful.
ps: With reference to materials found in tango_with_django and pythonanywhere.
Run python interpreter, bash shell and MySQL consoles. Share instances of shell with anyone. :)