Openshift > Django application on Openshift
Author: Anastasia Panchenko
Feb. 19, 2015, 6:40 a.m.

There were few changes in application structure on Openshift after its last release (https://blog.openshift.com/openshift-online-march-2014-release-blog/). Because of this I had some troubles with creating new Django application. Here I will describe steps for creating Django 1.7 application using Python 2.7 cartridge on Openshift.

1. Create application

There are two options for creating application on Openshift:

  • using command line tools 
  • using GUI 

Both of these are described here https://developers.openshift.com/en/getting-started-overview.html#step3

2. Clone application to development machine

Create empty Git repository on your machine:

mkdir repo_dir && cd repo_dir

git init

Open your application and copy its SSH path (via GUI or by command rhc domain show). It should be like 

ssh://ghsfg8o74658ofgsgcsrdyetniuet47tcn@your-app.rhcloud.com/~/git/your-app.git/

Clone it to your git repo:

git clone ssh://ghsfg8o74658ofgsgcsrdyetniuet47tcn@your-app.rhcloud.com/~/git/your-app.git/

You should see the following files structure:

repo_dir
    |-- requirements.txt
    |-- setup.py
    |-- wsgi.py

3. Create Django project

a) Install Django

pip install Django==1.7

b) Create your Django project

I use project template for this purpose https://github.com/AnaPana/django-project-template/blob/master/README.rst. In this case my command is

django-admin.py startproject --template=https://github.com/AnaPana/django-project-template/archive/master.zip --extension=py,js,css,html,txt my_project

Or empty default project can be created:

django-admin.py startproject my_project

c) Rearange project directories

If project was created from template, its root directory should be moved on one level up.

d) Final project structure

Finally there should the following project's structure:

repo_dir
    |-- my_project
        |-- manage.py
        └-- my_project
            |-- settings.py (or settings/production.py. settings/local.py etc)
            |-- urls.py
            └-- wsgi.py
    |-- requirements.txt
    |-- requirements/production.txt etc. (optional)
    |-- setup.py
    └-- wsgi.py

4. Configure wsgi.py file

The next step is to put this content into repo_dir/wsgi.py:

In my case it has the following code:

# wsgi.py
import os
from os.path import abspath, dirname
from sys import path

SITE_ROOT = dirname(dirname(abspath(__file__)))
path.append(SITE_ROOT)
path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'my_project'))

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings.production")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

There should be proper path to your DJANGO_SETTINGS_MODULE.

5. Add requirements

Put your requirements in requirements.txt file, e.g.:

# requirements.txt
Django==1.7

6. Push commit to Openshift

Do commands:

git add *

git commit -m "First commit"

git push origin master

 

Enjoy your web application) Don't forget to add your web-app site address to ALLOWED_HOSTS in production settings. If you have questions just leave a comment. I'll be happy to help you.

application
openshift
django
Ou Acheter Du Cialis A Paris Viagra Online No Precription [url=http://costofcial.com]cialis online[/url] Levitra Neu Keflex 700 Mg Will Amoxicillin Help Hand Foot Mouth Least Expensive Viagra Prescription Levitra Precio En Farmacia online pharmacy Cialis Indicacion Propecia Hepatitis C Buy Cheap Viagra Online Uk Vanuatu Pharmacy Online http://costofcial.com - online pharmacy Viagra Mexico Acquista Viagra Senza Ricetta
cheap ed meds online ed medicines generic for erectile dysfunction ed medications best ed medication what are the best generic ed drugs online erectile dysfunction medications ed medications compared cheap ed medication ed medications online ed drugs online best erectile dysfunction medication in canada ed drugs meds for ed erectile dysfunction medications sold in canada erectile dysfunction drugs generic ed drugs cheap erectile dysfunction drugs-canada canadian erectile dysfunction drugs ED medication order erectile dysfunction medication generic drugs for erectile dysfunction erectile meds ed drug cost comparison buy erectile dysfunction drugs generic ed medication erectile dysfunction medication prices ed meds on line cheap ed drugs best erectile dysfunction drugs for sale online erectile dysfunction drugs online meds for erectile dysfunction generic ed meds erectile dysfunction drugs canada ed drug best ed drug best deal on ED meds cheap ed meds medication from canada ed erectile dysfunction generic name for ED drugs buy erectile dysfunction drugs online cheap erectile dysfunction medication generic erectile dysfunction medications erectile dysfunction drugs comparison impotence drugs online common drugs for ed generic impotence drugs ed meds cost effective ed drugs canadian erectile dysfunction drugs buy diprosalic no prescription uk cialis vs viagra amoxicillin buy uk overnite lexapro pfizer brand viagra 100mg brand viagra 100mg mexican pharmacy no prescription needed viagra samples overnight cialis without a doctor's prescription
cialis and ocd [url=http://cialisle.com]generic cialis[/url] cialis and impotence buy generic cialis whats the highest dosage of cialis

Leave a comment:

Name
Python
Web development
Review Linux
Administration
Provisioning CVS
Windows AWS
Continuous Integration
NoSql Logging Web Servers FileSystems Scala
accurev ansible apach2 apache api application approaches architecture archivation argparse arguments artifactory automation awk aws backup bash batch-scripting beaver block build built-in caching call captcha cartridge case certificates cgi chain client cloud cloudformation cluster cmd coding collections command-line commands compression conditionals conversion convert cookbook copy counter cron crud css cut cygwin daemon datatype date dd debpackage decorator delattr deploy deque dict distributed-file-systems django DNS domain driver dropbox dump elasticcache elasticsearch encryption exit ext4 extra-tags failover file filename filters for form format freetds functions gerrit getattribute gid git globals glusterfs hardware hook iam indexing inheritance init install job-interview jquery ldap linux list locals logging logs logstash lookup magicmethods mail main-menu metadata metalogger mongodb moosefs mount mssql multiplatform multithreading mysql netcat nginx nosql open-ssh openldap openshift os packaging parse partition path pattern patterns permissions pid pil pip pipe playbook pool post post-commit processes production provisioning proxy putty python python-mysql recursively redirection redis register replication repr restore return review rotation scala script search selenium server setattr settings setup shipper signals singleton slots snapshot socket splunk ssh ssh-key ssl storage str string style subprocess sugar super switch syntactic syntaxhighlighter systeminfo tail tar templatetags time tls tune2fs tuple ubuntu unicode unique unix unixodbc usage usecases uuid uwsgi variable vars version vi virtualenv volume web web-server windows with_items __getattr__