diff --git a/core/__pycache__/context_processors.cpython-311.pyc b/core/__pycache__/context_processors.cpython-311.pyc
index bbf87e5..43aa9a8 100644
Binary files a/core/__pycache__/context_processors.cpython-311.pyc and b/core/__pycache__/context_processors.cpython-311.pyc differ
diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc
index 6b2a9ed..50c3078 100644
Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ
diff --git a/core/context_processors.py b/core/context_processors.py
index ff25dd6..a7be27d 100644
--- a/core/context_processors.py
+++ b/core/context_processors.py
@@ -19,12 +19,18 @@ def project_context(request):
def global_settings(request):
settings = None
try:
+ # Use a quick query to avoid hangs if DB is locked
settings = SystemSetting.objects.first()
if not settings:
- settings = SystemSetting.objects.create()
- except Exception:
- # If DB is broken (OperationalError, etc.), just return None.
- # Do not try to fix it here to avoid infinite loops or crashes during template rendering.
+ # Only attempt creation if we are absolutely sure it's missing
+ # and wrap it in a try-except to avoid crashes on read-only DBs
+ try:
+ settings = SystemSetting.objects.create(business_name="Meezan Accounting")
+ except Exception as e:
+ logger.error(f"Failed to create SystemSetting: {e}")
+ settings = None
+ except Exception as e:
+ logger.warning(f"Database error in global_settings: {e}")
pass
return {
diff --git a/core/templates/base.html b/core/templates/base.html
index c60e529..d8d8ead 100644
--- a/core/templates/base.html
+++ b/core/templates/base.html
@@ -27,6 +27,8 @@
{% endif %}
+
+
{% block head %}{% endblock %}
@@ -494,7 +496,9 @@
+
+
{% block scripts %}{% endblock %}