From 23a324a6f958e75cdd2e3d0d3af56ed97113d252 Mon Sep 17 00:00:00 2001 From: Thomas Marquart Date: Tue, 11 Aug 2020 12:59:12 +0200 Subject: [PATCH] various fixes for django 3.1 and deployment with Caddy --- browse/templates/indigo.html | 28 +++++++--------------------- manage.py | 19 +++++++++++++++---- settings.py | 31 +++++++++++++++++++++++-------- static/admin | 1 - static/css/indigo.css | 17 ++++++++--------- static/static | 1 + 6 files changed, 54 insertions(+), 43 deletions(-) delete mode 120000 static/admin create mode 120000 static/static diff --git a/browse/templates/indigo.html b/browse/templates/indigo.html index 9bf6201..a4ebdf7 100644 --- a/browse/templates/indigo.html +++ b/browse/templates/indigo.html @@ -1,3 +1,4 @@ +{% load static %} @@ -6,7 +7,7 @@ - + {% block title %}VAMDC dictionary{% endblock %} {% block addheader %}{% endblock %} @@ -18,14 +19,8 @@
-

{% block headline %}The VAMDC dictionary{% endblock %}

+

The VAMDC dictionary

-
@@ -46,26 +41,17 @@

{% block headline %}The VAMDC dictionary{% endblock %}

Dictionary

Links

-

{% endblock %} {% block sidebar2 %} diff --git a/manage.py b/manage.py index f9726f9..b184626 100755 --- a/manage.py +++ b/manage.py @@ -1,10 +1,21 @@ #!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" import os import sys -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") - - from django.core.management import execute_from_command_line +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/settings.py b/settings.py index f5f27bc..465c734 100644 --- a/settings.py +++ b/settings.py @@ -15,6 +15,8 @@ } } +STATIC_URL='/static/' +STATIC_ROOT='./static/' TIME_ZONE = 'Europe/Stockholm' LANGUAGE_CODE = 'en-us' SITE_ID = 1 @@ -22,14 +24,12 @@ USE_L10N = False MEDIA_ROOT = '' MEDIA_URL = '' -SECRET_KEY = '%l%4o(43#bv8&$7j=9!+%k+!vkpf*kg3@62js983' -ROOT_URLCONF = 'urls' -STATIC_URL = '/' -#STATIC_ROOT='/opt/VamdcDictionary/static' -ALLOWED_HOSTS=['*'] -TEST_RUNNER = 'django.test.runner.DiscoverRunner' +SECRET_KEY = '%l%4o(43#bv5&$7j=9!+%k+!vkpf*kg3@62js983' + +ROOT_URLCONF = 'urls' APPEND_SLASH = True +ALLOWED_HOSTS=['*'] TEMPLATES = [ { @@ -51,7 +51,7 @@ 'django.template.loaders.app_directories.Loader', ) -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -65,7 +65,22 @@ 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', -# 'django.contrib.staticfiles', + 'django.contrib.staticfiles', 'django.contrib.admin', 'browse', ) + +LOGGING = { + 'version': 1, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + } + }, + 'loggers': { + 'django.db.backends': { + 'level': 'DEBUG', + 'handlers': ['console'], + } + } +} diff --git a/static/admin b/static/admin deleted file mode 120000 index 3d9095c..0000000 --- a/static/admin +++ /dev/null @@ -1 +0,0 @@ -/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/ \ No newline at end of file diff --git a/static/css/indigo.css b/static/css/indigo.css index e347283..4f59a92 100644 --- a/static/css/indigo.css +++ b/static/css/indigo.css @@ -7,7 +7,6 @@ URL: http://arcsin.se Feel free to use and modify but please provide credits. #############################################################*/ - /* standard elements */ * { margin: 0; @@ -20,7 +19,7 @@ a:hover { color: #C60; } body { - background: #0094D6 url(/img/bg.gif) repeat-x; + background: #0094D6 url(/static/img/bg.gif) repeat-x; color: #466; font: normal 62.5% "Lucida Sans Unicode",sans-serif; margin: 0; @@ -38,7 +37,7 @@ h1 { margin-bottom: 4px; } code { - background: url(/img/bgcode.gif); + background: url(/static/img/bgcode.gif); border: 1px solid #F0F0F0; border-left: 6px solid #39F; color: #555; @@ -49,7 +48,7 @@ code { white-space: pre; } cite { - background: url(/img/quote.gif) no-repeat; + background: url(/static/img/quote.gif) no-repeat; color: #666; display: block; font: normal 1.3em "Lucida Sans Unicode",serif; @@ -66,7 +65,7 @@ h1,h2,h3 { /* structure */ .container { - background: url(/img/topleft.gif) no-repeat; + background: url(/static/img/topleft.gif) no-repeat; } .header { @@ -107,7 +106,7 @@ h1,h2,h3 { /* main */ .main { - background: #FFF url(/img/bgmain.gif) no-repeat; + background: #FFF url(/static/img/bgmain.gif) no-repeat; clear: both; padding: 12px 12px 0 52px; } @@ -142,7 +141,7 @@ h1,h2,h3 { } .sidenav li a:hover { color: #111; - background: url(/img/nav_li.gif) no-repeat; + background: url(/static/img/nav_li.gif) no-repeat; } /* content */ @@ -156,7 +155,7 @@ h1,h2,h3 { margin-bottom: 6px; } .content li { - list-style: url(/img/li.gif); + list-style: url(/static/img/li.gif); margin-left: 18px; } @@ -173,7 +172,7 @@ h1,h2,h3 { /* footer */ .footer { - background: #0094D6 url(/img/bgfooter.gif) repeat-x; + background: #0094D6 url(/static/img/bgfooter.gif) repeat-x; color: #C1DEF0; font-size: 1.1em; line-height: 40px; diff --git a/static/static b/static/static new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/static/static @@ -0,0 +1 @@ +. \ No newline at end of file