diff --git a/scripts/daemon.py b/scripts/daemon.py
index 312a1d90..67f6719a 100755
--- a/scripts/daemon.py
+++ b/scripts/daemon.py
@@ -32,6 +32,9 @@ import render
from www.maposmatic.models import MapRenderingJob
from www.settings import RENDERING_RESULT_PATH, RENDERING_RESULT_MAX_SIZE_GB
+import django
+django.setup()
+
_DEFAULT_CLEAN_FREQUENCY = 20 # Clean thread polling frequency, in
# seconds.
_DEFAULT_POLL_FREQUENCY = 10 # Daemon job polling frequency, in seconds
diff --git a/www/manage.py b/www/manage.py
deleted file mode 100755
index d6b7f8c1..00000000
--- a/www/manage.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/python
-# coding: utf-8
-
-# maposmatic, the web front-end of the MapOSMatic city map generation system
-# Copyright (C) 2009 David Decotigny
-# Copyright (C) 2009 Frédéric Lehobey
-# Copyright (C) 2009 David Mentré
-# Copyright (C) 2009 Maxime Petazzoni
-# Copyright (C) 2009 Thomas Petazzoni
-# Copyright (C) 2009 Gaël Utard
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-from django.core.management import execute_manager
-try:
- import settings # Assumed to be in the same directory.
-except ImportError:
- import sys
- sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
- sys.exit(1)
-
-if __name__ == "__main__":
- execute_manager(settings)
diff --git a/www/maposmatic.wsgi.dist b/www/maposmatic.wsgi.dist
index cac11bcd..c45f6371 100644
--- a/www/maposmatic.wsgi.dist
+++ b/www/maposmatic.wsgi.dist
@@ -30,6 +30,5 @@ os.environ["DJANGO_SETTINGS_MODULE"] = 'www.settings'
os.environ["MAPOSMATIC_LOG_FILE"] = "/tmp/maposmatic-www.log"
os.environ["PGCONNECT_TIMEOUT"] = 1
-import django.core.handlers.wsgi
-
-application = django.core.handlers.wsgi.WSGIHandler()
+from django.core.wsgi import get_wsgi_application
+application = get_wsgi_application()
diff --git a/www/maposmatic/views.py b/www/maposmatic/views.py
index 8a36aa41..a327265b 100644
--- a/www/maposmatic/views.py
+++ b/www/maposmatic/views.py
@@ -247,14 +247,14 @@ def api_nominatim(request):
contents = []
return HttpResponse(content=json_encode(contents),
- mimetype='text/json')
+ content_type='text/json')
def api_nominatim_reverse(request, lat, lon):
"""Nominatim reverse geocoding query gateway."""
lat = float(lat)
lon = float(lon)
return HttpResponse(json_encode(nominatim.reverse_geo(lat, lon)),
- mimetype='text/json')
+ content_type='text/json')
def api_papersize(request):
"""API handler to get the compatible paper sizes for the provided layout
@@ -301,7 +301,7 @@ def api_papersize(request):
key = lambda p: p[1])
return HttpResponse(content=json_encode(paper_sizes),
- mimetype='text/json')
+ content_type='text/json')
def api_bbox(request, osm_id):
@@ -317,7 +317,7 @@ def api_bbox(request, osm_id):
bbox_wkt, area_wkt = renderer.get_geographic_info(osm_id)
bbox = ocitysmap.coords.BoundingBox.parse_wkt(bbox_wkt)
return HttpResponse(content=json_encode(bbox.as_json_bounds()),
- mimetype='text/json')
+ content_type='text/json')
except:
LOG.exception("Error calculating bounding box for OSM ID %d!" % osm_id)
diff --git a/www/templates/maposmatic/base.html b/www/templates/maposmatic/base.html
index 040b2ec4..c762097f 100644
--- a/www/templates/maposmatic/base.html
+++ b/www/templates/maposmatic/base.html
@@ -66,11 +66,11 @@