Giter Club home page Giter Club logo

django-ex's Issues

add new build environment variable to allow this template to be easily deployed in air gapped environments

When deploying this template or any python based application in an air gapped, disconnected or non standard environment where the custom pypi is non standard the build pod fails to build because it does not trust the certificate of the provided custom pypi server. The way we have been able to get around this has been to add a build environment variable named PIP_TRUSTED_HOST and set its value to the FQDN or IP of the custom server. Adding alongside the PIP_INDEX_URL will allow for easier deployment. In standard environment that variable would not be needed.

Dead links

Both master and 1.11.x branches contains a lot of dead links to OpenShift documentation. Also, it would be nice to test this project with the lastest OpenShift.

Any volunteers?

Met "can't open file 'app.py': [Errno 2] No such file or directory"

  1. Login openshift and create project for the user

$ osc login --server=$master -u $user -p $password
$ osc new-project test

  1. Create imageStream

$ osc create -f image-streams-centos7.json
(the file "image-streams-centos7.json" is same with https://github.com/openshift/origin/blob/master/examples/image-streams/image-streams-centos7.json)

  1. Login openshift in web console

  2. Create application in console

"Create.." -> Input repo url "https://github.com/openshift/django-ex" -> "Next" -> Select a builder image "python:latest" -> finish create

  1. Start a build in webconsole

Browse -> Builds -> "Start Build"

  1. Wait build to complete and keep an eye on the log of pod

$ osc get pod
$ osc logs django-ex-1-c4x9k

_log messages as below_****

python manage.py migrate --noinput
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles, debug_toolbar
Apply all migrations: sessions, auth, admin, welcome, contenttypes
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sessions.0001_initial... OK
Applying welcome.0001_initial... OK
Metadata-Version: 2.0
Name: gunicorn
Version: 19.3.0
Summary: WSGI HTTP Server for UNIX
Home-page: http://gunicorn.org
Author: Benoit Chesneau
Author-email: [email protected]
License: MIT
Location: /opt/openshift/src/.local/lib/python3.3/site-packages
Requires:
python: can't open file 'app.py': [Errno 2] No such file or directory

Met AttributeError: 'NoneType' object has no attribute 'upper'

  1. Login openshift and create project for the user

$ osc login --server=$master -u $user -p $password
$ osc new-project test

  1. Create imageStream

$ osc create -f image-streams-centos7.json
(the file "image-streams-centos7.json" is same with https://github.com/openshift/origin/blob/master/examples/image-streams/image-streams-centos7.json)

  1. Login openshift in web console

  2. Create application in console

"Create.." -> Input repo url "https://github.com/openshift/django-ex" -> "Next" -> Select a builder image "python:latest" -> finish create

  1. Start a build in webconsole

Browse -> Builds -> "Start Build"

  1. Wait build complete and check the log of pod

$ osc get pod
$ osc log django-ex-1-y6hc1

_log messages as below_****

  • python manage.py migrate --noinput
    Traceback (most recent call last):
    File "manage.py", line 10, in
    execute_from_command_line(sys.argv)
    File "/opt/openshift/src/.local/lib/python3.3/site-packages/django/core/management/init.py", line 338, in execute_from_command_line
    utility.execute()
    File "/opt/openshift/src/.local/lib/python3.3/site-packages/django/core/management/init.py", line 303, in execute
    settings.INSTALLED_APPS
    File "/opt/openshift/src/.local/lib/python3.3/site-packages/django/conf/init.py", line 48, in getattr
    self._setup(name)
    File "/opt/openshift/src/.local/lib/python3.3/site-packages/django/conf/init.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
    File "/opt/openshift/src/.local/lib/python3.3/site-packages/django/conf/init.py", line 92, in init
    mod = importlib.import_module(self.SETTINGS_MODULE)
    File "/opt/rh/python33/root/usr/lib64/python3.3/importlib/init.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "", line 1586, in _gcd_import
    File "", line 1567, in _find_and_load
    File "", line 1534, in _find_and_load_unlocked
    File "", line 586, in _check_name_wrapper
    File "", line 1024, in load_module
    File "", line 1005, in load_module
    File "", line 562, in module_for_loader_wrapper
    File "", line 870, in _load_module
    File "", line 313, in _call_with_frames_removed
    File "/opt/openshift/src/project/settings.py", line 87, in
    'default': database.config()
    File "/opt/openshift/src/project/database.py", line 14, in config
    service_name = os.getenv('DATABASE_SERVICE_NAME').upper()
    AttributeError: 'NoneType' object has no attribute 'upper'

changing group not permitted, failed to kill container

Post-processed 'debug_toolbar/img/close_hover.png' as 'debug_toolbar/img/close_hover.2592d7057d2c.png'

79 static files copied to '/opt/app-root/src/staticfiles', 79 post-processed.
chgrp: changing group of ‘/opt/app-root/lib/python3.5/struct.py’: Operation not permitted
chgrp: changing group of ‘/opt/app-root/lib/python3.5/tempfile.py’: Operation not permitted
chgrp: changing group of ‘/opt/app-root/lib/python3.5/codecs.py’: Operation not permitted

warning: Failed to kill container "ac4d9f3e61a1873bc0742f44243e0c4b8d463d01bf543d15017fe952c9cd972a": Error response from daemon: {"message":"Cannot kill container ac4d9f3e61a1873bc0742f44243e0c4b8d463d01bf543d15017fe952c9cd972a: Container ac4d9f3e61a1873bc0742f44243e0c4b8d463d01bf543d15017fe952c9cd972a is not running"}

Can't connect to service with dashes in name

When the environment variable DATABASE_SERVICE_NAME contains dashes, database.py doesn't convert the dashes (-) into underscores (_) (code). This causes Django to fail to connect to the database.

For example, if my Openshift service is named foo-1, the corresponding environment variables are FOO_1_SERVICE_HOST and FOO_1_SERVICE_PORT. However, database.py tries to get the environment variables FOO-1_SERVICE_HOST and FOO-1_SERVICE_PORT (code), which aren't defined environment variables. Thus, HOST and PORT are set to None.

./run-in-container

Need to check t this.

./run-in-container.sh is not needed since there is no such file in the app-root.
Just run manage.py createsuperuser from the terminal of a running pod.

Branch 2.2.x sqlite version problem

I have tried to deploy branch 2.2.x to OpenShift with sqlite and the build ended with an error.

Build works fine, but when pod starts it ends in a CrashLoopBackOff state. I can see in the logs:

django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).

It seems that the default builder image for Python 3.6 has old sqlite version...

Static folder

I tried to configure my static folder without success.
In the setting file you have STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')but I don't find this folder on the repo

Someone can help me to configure my static folder ?

Changes for django 2.1 support

In starting to build the django 2.x PR for this repo, i ran into a basic issue, django 2.1+ requires SQlite 3.8 or higher, and looks like 3.7 is installed on the python S2I builds.

django 2.0 runs fine with minor changes.

Need SQlite 3.8 installed for 2.1 to run :)

Django Admin

I want to do createsuperuser ( python manage.py createsuperuser )on remote pod. So i did it through oc rsh pod_name .

But, whenever i push the code to repository, the admin settings are changing. That means I have to re-run the oc rsh pod_name command

How can I avoid this repeating procedure ?

Log python

I tried to debug my app but I don't find python log with
rhc tail -a project
Or when I got to /var/lib/openshift/id/app-root/logs/python.log file I don't find more log than displayed at screen

How can I see all my python output console ?

Different database password in Django and PostgreSQL containers

In the current example template, the Django and PostgreSQL containers are in separate DeploymentConfig's. I have a CI pipeline that processes the template, and since I leave the DATABASE_PASSWORD parameter blank (intentional), it is generated every time the pipeline runs. However, this doesn't trigger a ConfigChange in either DeploymentConfig because the environment variables are secret references (it seems like this would be the obvious thing to do). The Django container does get re-built as part of my CI pipeline and triggers an ImageChange, so the result is that I end up with a Django container that has a different database password in its environment variables from my PostgreSQL container.

Has anyone figured out how to solve this problem? I thought maybe if we put both containers in the same DeploymentConfig or have both the containers be restarted when the Django image changes... but neither seems ideal. Is there a way to specify an annotation that results in the Deployments being recreated when the Secret is updated?

manage.py import error

When running

oc new-app --file https://raw.githubusercontent.com/openshift/django-ex/master/openshift/templates/django.json

on the latest RHEL or CentOS devenv, I'm noticing the following error in the build:

I0302 20:15:44.120427       1 common.go:134] Running post commit hook with image hwlzr/django-example-1:a2264c0c ...
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
F0302 20:15:45.168126 1 builder.go:204] Error: build error: container "openshift_s2i-build_django-example-1_hwlzr_post-commit" returned non-zero exit code: 1

The client machine is Fedora 23 x64, with
oc v1.1.3-232-gf39a5a8
kubernetes v1.2.0-alpha.7-703-gbc4550d
etcd 2.2.5

I will try this evening to test against the lastest Fedora 'origin', @csrwng indicated some success with that.

Git Push not reflecting changes

Git push doesn't reflect the new addition and changes in local branch. How is that possible ?

List directories on openshift

VIEWS_BASE_DIR welcome templates welcome
['index.html']

On local
VIEWS_BASE_DIR welcome templates welcome
['index.html', 'index0.html', 'indexa.html', 'LBase', 'Portfolio', 'services.html', 'sidebar.html']

Upgrade to Django 2.2

I've tried to use django 2.2, but the collect static portion of the deploy no longer runs properly.

Unable to start django

Hello - I just tried deploying this to OpenShift and could not get the django pod to start up. The postgresql has no issues. Any ideas what may be causing this? Thanks.

NAME                             READY     STATUS             RESTARTS   AGE
django-psql-persistent-1-build   0/1       Completed          0          26m
django-psql-persistent-1-jtg64   0/1       CrashLoopBackOff   7          18m
postgresql-1-cqlp2               1/1       Running            0          26m

This is the error from the logs.


---> Migrating database ...
--
  | Operations to perform:
  | Apply all migrations: admin, auth, contenttypes, sessions, welcome
  | Running migrations:
  | No migrations to apply.
  | ---> Serving application with gunicorn (wsgi) ...
  | [2019-08-28 18:18:09 +0000] [1] [INFO] Starting gunicorn 19.4.5
  | [2019-08-28 18:18:09 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080  (1)
  | [2019-08-28 18:18:09 +0000] [1] [INFO] Using worker: sync
  | [2019-08-28 18:18:09 +0000] [41] [INFO] Booting worker with pid: 41
  | [2019-08-28 18:18:10 +0000] [42] [INFO] Booting worker with pid: 42
  | [2019-08-28 18:18:10 +0000] [43] [INFO] Booting worker with pid: 43
  | [2019-08-28 18:18:10 +0000] [45] [INFO] Booting worker with pid: 45
  | [2019-08-28 18:18:10 +0000] [44] [INFO] Booting worker with pid: 44
  | [2019-08-28 18:18:11 +0000] [46] [INFO] Booting worker with pid: 46
  | [2019-08-28 18:18:11 +0000] [47] [INFO] Booting worker with pid: 47
  | [2019-08-28 18:18:12 +0000] [49] [INFO] Booting worker with pid: 49
  | [2019-08-28 18:18:12 +0000] [48] [INFO] Booting worker with pid: 48
  | [2019-08-28 18:18:12 +0000] [51] [INFO] Booting worker with pid: 51
  | [2019-08-28 18:18:13 +0000] [50] [INFO] Booting worker with pid: 50
  | [2019-08-28 18:18:40 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:41)
  | [2019-08-28 18:18:40 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:42)
  | [2019-08-28 18:18:40 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:43)
  | [2019-08-28 18:18:40 +0000] [1] [INFO] Handling signal: term
  | [2019-08-28 18:18:40 +0000] [42] [INFO] Worker exiting (pid: 42)
  | [2019-08-28 18:18:41 +0000] [41] [ERROR] Exception in worker process:
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 176, in handle_abort
  | sys.exit(1)
  | SystemExit: 1
  |  
  | The above exception was the direct cause of the following exception:
  |  
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
  | worker.init_process()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 122, in init_process
  | self.load_wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
  | self.wsgi = self.app.wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
  | self.callable = self.load()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
  | return self.load_wsgiapp()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
  | return util.import_app(self.app_uri)
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/util.py", line 357, in import_app
  | __import__(module)
  | File "/opt/app-root/src/wsgi.py", line 16, in <module>
  | application = get_wsgi_application()
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
  | django.setup(set_prefix=False)
  | File "/opt/app-root/lib/python3.6/site-packages/django/__init__.py", line 20, in setup
  | from django.utils.log import configure_logging
  | File "/opt/app-root/lib/python3.6/site-packages/django/utils/log.py", line 8, in <module>
  | from django.core import mail
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/mail/__init__.py", line 11, in <module>
  | from django.core.mail.message import (
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/mail/message.py", line 12, in <module>
  | from email.mime.base import MIMEBase
  | File "/opt/rh/rh-python36/root/usr/lib64/python3.6/email/mime/base.py", line 9, in <module>
  | import email.policy
  | File "/opt/rh/rh-python36/root/usr/lib64/python3.6/email/policy.py", line 9, in <module>
  | from email.contentmanager import raw_data_manager
  | File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  | File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  | File "<frozen importlib._bootstrap>", line 894, in _find_spec
  | File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
  | File "<frozen importlib._bootstrap_external>", line 1129, in _get_spec
  | File "<frozen importlib._bootstrap_external>", line 1271, in find_spec
  | File "<frozen importlib._bootstrap_external>", line 96, in _path_isfile
  | File "<frozen importlib._bootstrap_external>", line 88, in _path_is_mode_type
  | File "<frozen importlib._bootstrap_external>", line 82, in _path_stat
  | SystemError: PyEval_EvalFrameEx returned a result with an error set
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 176, in handle_abort
  | sys.exit(1)
  | SystemExit: 1
  |  
  | The above exception was the direct cause of the following exception:
  |  
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
  | worker.init_process()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 122, in init_process
  | self.load_wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
  | self.wsgi = self.app.wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
  | self.callable = self.load()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
  | return self.load_wsgiapp()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
  | return util.import_app(self.app_uri)
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/util.py", line 357, in import_app
  | __import__(module)
  | File "/opt/app-root/src/wsgi.py", line 16, in <module>
  | application = get_wsgi_application()
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
  | django.setup(set_prefix=False)
  | File "/opt/app-root/lib/python3.6/site-packages/django/__init__.py", line 20, in setup
  | from django.utils.log import configure_logging
  | File "/opt/app-root/lib/python3.6/site-packages/django/utils/log.py", line 8, in <module>
  | from django.core import mail
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/mail/__init__.py", line 11, in <module>
  | from django.core.mail.message import (
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/mail/message.py", line 12, in <module>
  | from email.mime.base import MIMEBase
  | File "/opt/rh/rh-python36/root/usr/lib64/python3.6/email/mime/base.py", line 9, in <module>
  | import email.policy
  | File "/opt/rh/rh-python36/root/usr/lib64/python3.6/email/policy.py", line 9, in <module>
  | from email.contentmanager import raw_data_manager
  | File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  | File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  | File "<frozen importlib._bootstrap>", line 894, in _find_spec
  | File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
  | File "<frozen importlib._bootstrap_external>", line 1129, in _get_spec
  | File "<frozen importlib._bootstrap_external>", line 1271, in find_spec
  | File "<frozen importlib._bootstrap_external>", line 96, in _path_isfile
  | File "<frozen importlib._bootstrap_external>", line 88, in _path_is_mode_type
  | File "<frozen importlib._bootstrap_external>", line 82, in _path_stat
  | SystemError: PyEval_EvalFrameEx returned a result with an error set
  | [2019-08-28 18:18:41 +0000] [41] [INFO] Worker exiting (pid: 41)
  | [2019-08-28 18:18:42 +0000] [43] [ERROR] Exception in worker process:
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
  | worker.init_process()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 122, in init_process
  | self.load_wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
  | self.wsgi = self.app.wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
  | self.callable = self.load()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
  | return self.load_wsgiapp()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
  | return util.import_app(self.app_uri)
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/util.py", line 357, in import_app
  | __import__(module)
  | File "/opt/app-root/src/wsgi.py", line 16, in <module>
  | application = get_wsgi_application()
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
  | django.setup(set_prefix=False)
  | File "/opt/app-root/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
  | apps.populate(settings.INSTALLED_APPS)
  | File "/opt/app-root/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
  | app_config.import_models()
  | File "/opt/app-root/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
  | self.models_module = import_module(models_module_name)
  | File "/opt/app-root/lib64/python3.6/importlib/__init__.py", line 126, in import_module
  | return _bootstrap._gcd_import(name[level:], package, level)
  | File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module>
  | from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  | File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
  | class AbstractBaseUser(models.Model):
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
  | new_class.add_to_class('_meta', Options(meta, app_label))
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/models/base.py", line 325, in add_to_class
  | value.contribute_to_class(cls, name)
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
  | self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
  | return getattr(connections[DEFAULT_DB_ALIAS], item)
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
  | backend = load_backend(db['ENGINE'])
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
  | return import_module('%s.base' % backend_name)
  | File "/opt/app-root/lib64/python3.6/importlib/__init__.py", line 126, in import_module
  | return _bootstrap._gcd_import(name[level:], package, level)
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 21, in <module>
  | import psycopg2 as Database
  | File "/opt/app-root/lib/python3.6/site-packages/psycopg2/__init__.py", line 50, in <module>
  | from psycopg2._psycopg import (                     # noqa
  | SystemError: initialization of _psycopg raised unreported exception
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
  | worker.init_process()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 122, in init_process
  | self.load_wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
  | self.wsgi = self.app.wsgi()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
  | self.callable = self.load()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
  | return self.load_wsgiapp()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
  | return util.import_app(self.app_uri)
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/util.py", line 357, in import_app
  | __import__(module)
  | File "/opt/app-root/src/wsgi.py", line 16, in <module>
  | application = get_wsgi_application()
  | File "/opt/app-root/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
  | django.setup(set_prefix=False)
  | File "/opt/app-root/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
  | apps.populate(settings.INSTALLED_APPS)
  | File "/opt/app-root/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
  | app_config.import_models()
  | File "/opt/app-root/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
  | self.models_module = import_module(models_module_name)
  | File "/opt/app-root/lib64/python3.6/importlib/__init__.py", line 126, in import_module
  | return _bootstrap._gcd_import(name[level:], package, level)
  | File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module>
  | from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  | File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
  | class AbstractBaseUser(models.Model):
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
  | new_class.add_to_class('_meta', Options(meta, app_label))
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/models/base.py", line 325, in add_to_class
  | value.contribute_to_class(cls, name)
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
  | self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
  | return getattr(connections[DEFAULT_DB_ALIAS], item)
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
  | backend = load_backend(db['ENGINE'])
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
  | return import_module('%s.base' % backend_name)
  | File "/opt/app-root/lib64/python3.6/importlib/__init__.py", line 126, in import_module
  | return _bootstrap._gcd_import(name[level:], package, level)
  | File "/opt/app-root/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 21, in <module>
  | import psycopg2 as Database
  | File "/opt/app-root/lib/python3.6/site-packages/psycopg2/__init__.py", line 50, in <module>
  | from psycopg2._psycopg import (                     # noqa
  | SystemError: initialization of _psycopg raised unreported exception
  | [2019-08-28 18:18:42 +0000] [43] [INFO] Worker exiting (pid: 43)
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 199, in run
  | handler()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 234, in handle_term
  | raise StopIteration
  | StopIteration
  |  
  | During handling of the above exception, another exception occurred:
  |  
  | Traceback (most recent call last):
  | File "/opt/app-root/bin/gunicorn", line 11, in <module>
  | sys.exit(run())
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
  | WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/base.py", line 192, in run
  | super(Application, self).run()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
  | Arbiter(self).run()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 202, in run
  | self.halt()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 302, in halt
  | self.stop()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 347, in stop
  | time.sleep(0.1)
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 219, in handle_chld
  | self.reap_workers()
  | File "/opt/app-root/lib/python3.6/site-packages/gunicorn/arbiter.py", line 464, in reap_workers
  | raise HaltServer(reason, self.WORKER_BOOT_ERROR)
  | gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>


Django version in requirements.txt

Django 1.8.X is the LTS version and has support until at least April 2018 why not update the requirements.txt to:

django==1.8.1 # now
django<=1.9

allowed_hosts

In Openshift2 I used to set allowed_hosts to an environment variable called OPENSHIFT_APP_DNS, but now I notice that you have used * in it's place.

Do we think this is safe since we are in a dedicated container now?

Just wanted to check.

thanks,

Whitenoise requirement?

I noticed that whitenoise is in the requirements.txt file, and it in the wsgy.py file, but in reading the docs from whitenoise, it doesn't seem to match the django setup.

Is this correct?

Add notes in documentation about tests triggered by build.

A section should be added to the documentation about how tests are being triggered by a "postCommit" in the build configuration. It is important to highlight it because its presence can break builds in a confusing way if people copy this repo as an example and change around how databases are setup and remove the fallback to SQLite.

Worst case would be someone who changed the code such that database information was available during the build phase. In this case they could run the tests against an external production database, which could be really bad as could be destructive of data.

So better to highlight what is being done with running tests during the build and how it is done.

This issue came about because a real world user did remove the fallback to SQLite and so all their builds were then failing and they had no idea.

Local development errors on macOS with postgresql 10.0

Local development does not work on macOS with postgresql 10.0:

$ brew info postgresql | head -1
postgresql: stable 10.0 (bottled), HEAD
$ pip install -r requirements.txt
[...]
Collecting psycopg2==2.6.1 (from -r requirements.txt (line 4))
  Downloading psycopg2-2.6.1.tar.gz (371kB)
    100% |████████████████████████████████| 378kB 2.2MB/s
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    Error: could not determine PostgreSQL version from '10.0'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/9_/k7p0mlkj41n03hf7kf85sXXXXXXXXX/T/pip-build-on90xxxx/psycopg2/

We should specify the latest version of psycopg2.

Found "SyntaxError: invalid syntax" while deploying through openshift/python-27-centos7 registry

Found the below error in build logs of django-ex

File "/tmp/pip-build-UPwlfC/gunicorn/gunicorn/workers/_gaiohttp.py", line 78
yield from self.wsgi.close()
^
SyntaxError: invalid syntax

Steps to reproduce:

  1. Create a new project (oc new-project python-test)
  2. Deploy the new app (oc new-app openshift/python-27-centos7~https://github.com/openshift/django-ex)
  3. Go to the build logs (oc logs -f bc/django-ex)
  4. Build is successful but in the build logs found an error as above

pg_config executable not found

When trying to spin up the application locally on Mac OS X, I got the error:

Collecting psycopg2==2.6.1 (from -r requirements.txt (line 4))
  Downloading psycopg2-2.6.1.tar.gz (371kB)
    100% |████████████████████████████████| 378kB 15kB/s 
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    Error: pg_config executable not found.
    
    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:
    
        python setup.py build_ext --pg-config /path/to/pg_config build ...
    
    or with the pg_config option in 'setup.cfg'.

I solved this by installing the following homebrew bottle.

$ brew install postgresql

Error: pg_config executable not found.

While installing with pip install -r requirements.txt on OS X El Capitan I get an error:

(OPENSHIFT_DJANGO) @MyMac[~/_GITHUB/django-ex]$ pip install -r requirements.txt
Collecting django<1.9,>=1.8 (from -r requirements.txt (line 1))
  Using cached Django-1.8.17-py2.py3-none-any.whl
Collecting django-debug-toolbar==1.5 (from -r requirements.txt (line 2))
  Using cached django_debug_toolbar-1.5-py2.py3-none-any.whl
Collecting gunicorn==19.4.5 (from -r requirements.txt (line 3))
  Using cached gunicorn-19.4.5-py2.py3-none-any.whl
Collecting psycopg2==2.6.1 (from -r requirements.txt (line 4))
  Using cached psycopg2-2.6.1.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found
    
    Error: pg_config executable not found.
    
    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:
    
        python setup.py build_ext --pg-config /path/to/pg_config build ...
    
    or with the pg_config option in 'setup.cfg'.
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/nr/46qp2z_s3wx14pwzl5s_dy6w0000gn/T/pip-build-hkjjeb8f/psycopg2/

Why is APP_CONFIG defined in the template?

I just spent 2hrs figuring out why my app_config values in my .s2i/environment setup didn't work, and it turns out that the template has a blank APP_CONFIG variable.

Is this there for a reason? It seems to collide with the .s2i documentation, or rather it's spirit.

Hello, I tried to run the code, but it shows

Hello, I tried to run the code, but it shows:
django.core.exceptions.ImproperlyConfigured: WSGI application 'application' could not be loaded; Error importing module: 'application doesn't look like a module path'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.