Skip to content
Snippets Groups Projects
Commit 5fcf242b authored by Dennis Ahrens's avatar Dennis Ahrens
Browse files

Raise django version and adjust settings to hsh structure

parent dea541c1
No related branches found
No related tags found
No related merge requests found
...@@ -9,5 +9,6 @@ ...@@ -9,5 +9,6 @@
build/ build/
dist/ dist/
venv/ venv/
helloworld.db db.sqlite3
helloworld/settings/private.py helloworld/settings/prod.py
helloworld/settings/dev.py
from helloworld.settings.common import * from .common import *
from helloworld.settings.logging import *
# this comes after all other settings (since private settings will override several values) try:
from helloworld.settings.private import * from .prod import *
_PRODUCTION = True
assert DEBUG is False, "DEBUG in development?!"
except ImportError:
_PRODUCTION = False
try:
from .dev import *
_DEVELOPMENT = True
except ImportError:
_DEVELOPMENT = False
assert _DEVELOPMENT ^ _PRODUCTION, "Bad settings: development {0}, production {1}".format(_DEVELOPMENT, _PRODUCTION)
\ No newline at end of file
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
# Django settings for helloworld project. # Django settings for helloworld project.
import os import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ADMINS = ( ADMINS = (
# ('Your Name', 'your_email@example.com'), # ('Your Name', 'your_email@example.com'),
...@@ -9,6 +12,15 @@ ADMINS = ( ...@@ -9,6 +12,15 @@ ADMINS = (
MANAGERS = ADMINS MANAGERS = ADMINS
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles'
)
# Local time zone for this installation. Choices can be found here: # Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems. # although not all choices may be available on all operating systems.
...@@ -99,15 +111,47 @@ TEMPLATE_DIRS = ( ...@@ -99,15 +111,47 @@ TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), "templates"), os.path.join(os.path.dirname(__file__), "templates"),
) )
INSTALLED_APPS = ( LOGGING = {
'django.contrib.auth', 'version': 1,
'django.contrib.contenttypes', 'disable_existing_loggers': False,
'django.contrib.sessions', 'formatters': {
'django.contrib.sites', 'with_timestamp': {
'django.contrib.messages', 'format': '[%(asctime)s %(levelname).3s %(process)d] %(message)s',
'django.contrib.staticfiles', 'datefmt': '%Y-%m-%d %H:%M:%S',
# Uncomment the next line to enable the admin: },
'django.contrib.admin', },
# Uncomment the next line to enable admin documentation: 'handlers': {
'django.contrib.admindocs', 'console': {
) 'stream': sys.stdout,
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'with_timestamp'
},
},
'loggers': {
'': {
'handlers': ['console'],
'level': 'DEBUG'
},
'django': {
'level': 'WARNING',
'handlers': ['console'],
'propagate': False,
},
'django.db': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
'pika': {
'level': 'WARNING',
'handlers': ['console'],
'propagate': False,
},
'pikatasks': {
'level': 'INFO',
'handlers': ['console'],
'propagate': False,
},
}
}
\ No newline at end of file
from .common import *
DEBUG = True
SECRET_KEY = str(getattr(os.uname(), "nodename"))
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
SESSION_COOKIE_SECURE = False
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "../db.sqlite3"),
}
}
LOGGING["handlers"]["console"]["level"] = "DEBUG"
PIKATASKS_BROKER_HOST = "localhost"
PIKATASKS_VIRTUAL_HOST = "idm"
PIKATASKS_SSL_ENABLED = False
PIKATASKS_BROKER_PORT = 5672 # No TLS/SSL
PIKATASKS_USERNAME = "accountmgr"
PIKATASKS_PASSWORD = ""
PIKATASKS_CLIENT_EXCHANGE_NAME = ""
try: # Colored logger CaaS. Auto downloaded and verified.
import os
import hashlib
from urllib import request
cache, url = "/tmp/_colored_logger.py", "https://lab.it.hs-hannover.de/lukyanch/pydevutils/raw/fa4af6555a8eb996e1be158ca12691de9b33ba45/colored_logger.py"
code = bool(os.path.exists(cache) or request.urlretrieve(url, cache)) and open(cache, "r").read()
assert hashlib.sha256(code.encode()).hexdigest() == "d4d261a40f95733f9fb184fc4ccb55d007b880cb62c8d6a06824d43eeb1391ac", "unrecognized content in " + cache
exec(code)
except Exception as e:
print("No colored logger: {e.__class__.__name__}: {e}".format(e=e))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'helloworld.db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Make this unique, and don't share it with anybody.
SECRET_KEY = '0h@p1(0e%*b9r4k+dnpc+7s18lpap6+=cu^#^d=hll+38zv_)r'
SECRET_KEY = r""
ALLOWED_HOSTS = []
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import patterns, include from django.conf.urls import url
from django.conf import settings from .views import index
# Uncomment the next two lines to enable the admin: urlpatterns = (
from django.contrib import admin url(r'', index),
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^helloworld/', include('helloworld.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
# Hello, world!
(r'', 'helloworld.views.index'),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
) )
# requirements.txt # requirements.txt
Django>=2.2,<2.3
Django==1.9.4 \ No newline at end of file
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment