diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index 84c539a8e..11f079f2f 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals, print_function +import codecs import getpass import os import shutil @@ -253,7 +254,7 @@ class DeployCommand(Command): 'extra_settings': extra_settings } ) - with open("%s/settings.py" % path, "w") as fp: + with codecs.open("%s/settings.py" % path, "w", "utf-8") as fp: fp.write(tpl) shutil.copyfile( "%s/urls.py.tpl" % self._templates_dir, "%s/urls.py" % path diff --git a/modoboa/core/commands/templates/settings.py.tpl b/modoboa/core/commands/templates/settings.py.tpl index af59cce7a..aca3abeaa 100644 --- a/modoboa/core/commands/templates/settings.py.tpl +++ b/modoboa/core/commands/templates/settings.py.tpl @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Django settings for {{ name }} project. @@ -39,6 +40,15 @@ ALLOWED_HOSTS = [ SITE_ID = 1 +# A list of all the people who get code error notifications. When DEBUG=False +# and a view raises an exception, Django will email these people with the full +# exception information. +# See https://docs.djangoproject.com/en/dev/ref/settings/#admins +#ADMINS = [('Administrator', 'admin@example.net')] + +# The email address that error messages come from, such as those sent to ADMINS +#SERVER_EMAIL = 'webmaster@example.net' + # Security settings X_FRAME_OPTIONS = "SAMEORIGIN" @@ -252,6 +262,11 @@ LOGGING = { }, }, 'handlers': { + 'mail-admins': { + 'level': 'ERROR', + 'class': 'django.utils.log.AdminEmailHandler', + 'include_html': True + }, 'syslog-auth': { 'class': 'logging.handlers.SysLogHandler', 'facility': SysLogHandler.LOG_AUTH, @@ -262,6 +277,11 @@ LOGGING = { } }, 'loggers': { + 'django': { + 'handlers': ['mail-admins'], + 'level': 'ERROR', + 'propagate': False + }, 'modoboa.auth': { 'handlers': ['syslog-auth', 'modoboa'], 'level': 'INFO',