sclorg / django-ex Goto Github PK
View Code? Open in Web Editor NEWDjango Example
Django Example
Update django-debug-toolbar from 1.5 to 1.8 to update django to the latest.
blocks #105
Update Django from 1.8 to 1.11 as Django 1.8 will be EOS in Apr 2018.
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.
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?
$ osc login --server=$master -u $user -p $password
$ osc new-project test
$ 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)
Login openshift in web console
Create application in console
"Create.." -> Input repo url "https://github.com/openshift/django-ex" -> "Next" -> Select a builder image "python:latest" -> finish create
Browse -> Builds -> "Start Build"
$ 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
$ osc login --server=$master -u $user -p $password
$ osc new-project test
$ 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)
Login openshift in web console
Create application in console
"Create.." -> Input repo url "https://github.com/openshift/django-ex" -> "Next" -> Select a builder image "python:latest" -> finish create
Browse -> Builds -> "Start Build"
$ osc get pod
$ osc log django-ex-1-y6hc1
_log messages as below_****
Update gunicorn from 19.4.5 to 19.8.1.
Instead of #117
Update gunicorn from 19.4.5 to 19.9.0.
Instead of #108
This issue is created for testing purpose. No action required.
Update gunicorn from 19.4.5 to 19.10.0 to address the following:
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"}
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
.
Why do we have the debug-toolbar in this repo?
Could we move it to a note in the readme.MD instead?
Just a thought.
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.
See PR#119 why it is needed.
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...
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 ?
Django 3.2 LTS is out: https://docs.djangoproject.com/en/3.2/releases/3.2/
We should prepare a new version of this example for this new release.
When I try to run django server manage.py . Error occur:
module_path, class_name = dotted_path.rsplit('.', 1)
ValueError: not enough values to unpack (expected 2, got 1)
WhiteNoise recommends enabling compression and caching:
http://whitenoise.evans.io/en/stable/django.html#add-compression-and-caching-support
We could test that it works and enable it.
Django 1.11.X LTS is out of support as of April 1, 2020. Branch 2.2.x
seems to have supported version of Django.
https://www.djangoproject.com/download/
How about switch 2.2.x
to master
?
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 :)
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 ?
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 ?
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?
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 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']
I've tried to use django 2.2, but the collect static portion of the deploy no longer runs properly.
It would be nice to use a newer version of the image centos/python-36-centos7
in readme example.
Hi,
I made a fork of this repository to run a Flask application on Openshift (https://github.com/renefs/flask-ex) I think It might be helpful for some people using this microframework. My question is: What is needed to add the quickstart here: https://docs.openshift.com/container-platform/3.11/dev_guide/migrating_applications/quickstart_examples.html ?
Cheers,
Rene
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 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
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,
@bparees is this supposed to be empty?
https://github.com/openshift/django-ex/blob/master/openshift/templates/django-postgresql.json#L305
my deployment fails on openshift with imagePullBackOff and something like
E0831 14:49:01.123388 1727 pod_workers.go:183] Error syncing pod e158c98e-6f78-11e6-
ada1-68f728fac2c0, skipping: failed to "StartContainer" for "postgresql" with ErrImagePull:
"couldn't parse image reference \" \": invalid reference format"
Update whitenoise from 3.0 to 3.3.1 to update django to the latest.
blocks #105
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?
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 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 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:
The Django python examples that are populated as quick-starts / examples in an OCP 4.x cluster, will not build on an OpenShift cluster with FIPS enabled.
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
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/
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:
django.core.exceptions.ImproperlyConfigured: WSGI application 'application' could not be loaded; Error importing module: 'application doesn't look like a module path'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.