Use django.db.connection as suggested

This commit is contained in:
tcely authored and GitHub committed 2024-12-12 15:19:54 -05:00
1 parent 3e5711f0f2
commit 730275746d
1 file changed
+3 -3
+3 -3
View File
@@ -14,7 +14,7 @@ from django.views.generic.detail import SingleObjectMixin
from django.core.exceptions import SuspiciousFileOperation
from django.http import HttpResponse
from django.urls import reverse_lazy
from django.db import IntegrityError
from django.db import connection, IntegrityError
from django.db.models import Q, Count, Sum, When, Case
from django.forms import Form, ValidationError
from django.utils.text import slugify
@@ -86,9 +86,9 @@ class DashboardView(TemplateView):
data['downloads_dir'] = str(settings.DOWNLOAD_ROOT)
data['database_connection'] = settings.DATABASE_CONNECTION_STR
# Add the database filesize when using db.sqlite3
db_name = str(settings.DATABASES["default"]["NAME"])
db_name = str(connection.get_connection_params()['database'])
db_path = pathlib.Path(db_name) if '/' == db_name[0] else None
if db_path and settings.DATABASE_CONNECTION_STR.startswith('sqlite at '):
if db_path and 'sqlite' == connection.vendor:
db_size = db_path.stat().st_size
data['database_connection'] += f' ({db_size:,} bytes)'
return data