diff --git a/welcome/database.py b/welcome/database.py new file mode 100644 index 00000000..2ac4a3fb --- /dev/null +++ b/welcome/database.py @@ -0,0 +1,22 @@ +from django.conf import settings + + +def info(): + db_settings = settings.DATABASES['default'] + if 'postgres' in db_settings['ENGINE']: + engine = 'PostgreSQL' + url = '{HOST}:{PORT}/{NAME}'.format(**db_settings) + elif 'mysql' in db_settings['ENGINE']: + engine = 'MySQL' + url = '{HOST}:{PORT}/{NAME}'.format(**db_settings) + elif 'sqlite' in db_settings['ENGINE']: + engine = 'SQLite' + url = '{NAME}'.format(**db_settings) + else: + engine = 'unknown' + url = '' + return { + 'engine': engine, + 'url': url, + 'is_sqlite': engine == 'SQLite', + } diff --git a/welcome/templates/welcome/index.html b/welcome/templates/welcome/index.html index 75e58c32..a26aa92a 100644 --- a/welcome/templates/welcome/index.html +++ b/welcome/templates/welcome/index.html @@ -14,6 +14,7 @@ #explanation { background:#eee; } #instructions { background:#f6f6f6; } #instructions ol li { margin: 0.2em 0 0.2em 2em; } + .warning { color: orange } @@ -51,7 +52,15 @@
Server hostname: {{ hostname }}
- Database server: {{ database_info }}
+ Database server: {{ database.engine }} ({{ database.url }})
+ {% if database.is_sqlite %}
+
+ Data persistence warning:
+ You are currently using SQLite.
+ This is fine for development, but your data won't be persisted
+ across application deployments.
+
+ {% endif %}
Page views: {{ count }}