Run Django on Oracle Application Container


I have an existing django project which I am trying to deploy to Oracle’s cloud service, Application Container.

I followed Oracle’s guide to do this however there are some details missing from this guide. Specifically the guide references an file which seems to come from this guide. But I can’t see how to use that in a django project.

I’ve tried replacing the calls to to use django’s or files but Oracle servers still fail to launch. The server logs Oracle provide also don’t help, only telling me the python packages are being installed.

ACCS[web.1]: Content of APP_HOME [ /u01/app/ ] dir
ACCS[web.1]: total 96
ACCS[web.1]: -rw-r----- 1 apaas apaas 28423 May 17 10:51 readme.html
ACCS[web.1]: -rw-r----- 1 apaas apaas 40960 May 17 10:51 db.sqlite3
ACCS[web.1]: -rw-r----- 1 apaas apaas   355 Sep 10 13:26
ACCS[web.1]: -rw-r----- 1 apaas apaas   254 Sep 10 13:28 DjangoProject.pyproj.user
ACCS[web.1]: -rw-r----- 1 apaas apaas  6990 Sep 10 13:28 DjangoProject.pyproj
ACCS[web.1]: -rw-r----- 1 apaas apaas   186 Sep 12 11:24 manifest.json
ACCS[web.1]: drwxr-x--- 1 apaas apaas    10 Sep 13 03:42 obj
ACCS[web.1]: drwxr-x--- 1 apaas apaas   160 Sep 13 03:42 app
ACCS[web.1]: drwxr-x--- 1 apaas apaas    94 Sep 13 03:42 DjangoProject
ACCS[web.1]: drwxr-xr-x 1 apaas apaas   286 Sep 13 03:42 .
ACCS[web.1]: drwxr-xr-x 1 apaas apaas    46 Sep 13 03:42 ..
ACCS[web.1]: -rw-r----- 1 apaas apaas   290 Sep 13  2018
ACCS[web.1]: -rw-r----- 1 apaas apaas    51 Sep 13  2018 requirements.txt
ACCS[web.1]: Application should listen on$PORT [enabling app to listen on all interfaces on $PORT env variable]
ACCS[web.1]: Starting application with launch command [ sh ./ ]
APP[web.1]: Collecting Django==1.11.15 (from -r ./requirements.txt (line 1))
APP[web.1]:   Downloading (6.9MB)
APP[web.1]: Collecting pytz==2018.5 (from -r ./requirements.txt (line 2))
APP[web.1]:   Downloading (510kB)
APP[web.1]: Collecting setuptools==39.0.1 (from -r ./requirements.txt (line 3))
APP[web.1]:   Downloading (569kB)
APP[web.1]: Installing collected packages: pytz, Django, setuptools
APP[web.1]: Successfully installed Django-1.11.15 pytz-2018.5 setuptools-39.0.1
APP[web.1]: You are using pip version 9.0.1, however version 18.0 is available.
APP[web.1]: You should consider upgrading via the 'pip install --upgrade pip' command.

I found use from this guide when making my file as well.

pip --no-cache-dir install -r ./requirements.txt -t modules
python runserver

I’ve contacted Oracle’s support but they were not able to find a solution either. Their recommendation was in include the PORT variable which the server uses in the file, which I tried.

import os
import sys

from import call_command
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DjangoMedmin.settings")
application = get_wsgi_application()

PORT_NUMBER = int(os.environ.get('PORT', 8084))
call_command('runserver',  ''+str(PORT_NUMBER))

What am I missing? Is it possible to have django work with Oracle?


With some more help from Oracle support I managed to get Django working on a Application Container.

The issue was with the ALLOWED_HOSTS variable in The tutorials I found all suggest using ALLOWED_HOSTS = ['*']. This does NOT work.

In order to get Django working I needed to include the specific URL Oracle assigns to the Application Container. So something like ALLOWED_HOSTS = [''].

Answered By – acheur

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published