diff --git a/config/__pycache__/settings.cpython-311.pyc b/config/__pycache__/settings.cpython-311.pyc index aaac9ec..b9c13a5 100644 Binary files a/config/__pycache__/settings.cpython-311.pyc and b/config/__pycache__/settings.cpython-311.pyc differ diff --git a/config/__pycache__/wsgi.cpython-311.pyc b/config/__pycache__/wsgi.cpython-311.pyc index 582bff8..1d0ee84 100644 Binary files a/config/__pycache__/wsgi.cpython-311.pyc and b/config/__pycache__/wsgi.cpython-311.pyc differ diff --git a/config/asgi.py b/config/asgi.py index ed7c431..46bbdf5 100644 --- a/config/asgi.py +++ b/config/asgi.py @@ -8,9 +8,18 @@ https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/ """ import os +from pathlib import Path + +try: + from dotenv import load_dotenv + env_path = Path(__file__).resolve().parent.parent.parent / '.env' + if env_path.exists(): + load_dotenv(env_path) +except ImportError: + pass from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') -application = get_asgi_application() +application = get_asgi_application() \ No newline at end of file diff --git a/config/settings.py b/config/settings.py index c8ae3b4..2d79ebf 100644 --- a/config/settings.py +++ b/config/settings.py @@ -38,13 +38,12 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', - 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'config.urls' @@ -60,7 +59,8 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'core.context_processors.deployment_timestamp', # Custom CP + 'core.context_processors.project_context', + 'core.context_processors.global_settings', ], }, }, @@ -141,6 +141,7 @@ SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = "None" CSRF_COOKIE_SAMESITE = "None" +# X_FRAME_OPTIONS = 'SAMEORIGIN' # Email Settings EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' diff --git a/config/wsgi.py b/config/wsgi.py index e2fbd58..6c87fb6 100644 --- a/config/wsgi.py +++ b/config/wsgi.py @@ -4,13 +4,22 @@ WSGI config for config project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ """ import os +from pathlib import Path + +try: + from dotenv import load_dotenv + env_path = Path(__file__).resolve().parent.parent.parent / '.env' + if env_path.exists(): + load_dotenv(env_path) +except ImportError: + pass from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') -application = get_wsgi_application() +application = get_wsgi_application() \ No newline at end of file diff --git a/core/__pycache__/apps.cpython-311.pyc b/core/__pycache__/apps.cpython-311.pyc index 0ea1680..ed8da76 100644 Binary files a/core/__pycache__/apps.cpython-311.pyc and b/core/__pycache__/apps.cpython-311.pyc differ diff --git a/core/apps.py b/core/apps.py index 787e163..8115ae6 100644 --- a/core/apps.py +++ b/core/apps.py @@ -1,16 +1,6 @@ from django.apps import AppConfig -import sys + class CoreConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'core' - - def ready(self): - if 'runserver' in sys.argv: - try: - from django.core.management import call_command - print("Gemini: Auto-running migrations...") - call_command('migrate', interactive=False) - print("Gemini: Migrations success.") - except Exception as e: - print(f"Gemini: Migration error: {e}") \ No newline at end of file diff --git a/core/migrations/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.py b/core/migrations/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.py index 9dad8f4..ad658ee 100644 --- a/core/migrations/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.py +++ b/core/migrations/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.py @@ -10,9 +10,15 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RemoveField( - model_name='systemsetting', - name='logo_url', + migrations.RunSQL( + sql="ALTER TABLE core_systemsetting DROP COLUMN IF EXISTS logo_url;", + reverse_sql="ALTER TABLE core_systemsetting ADD COLUMN IF NOT EXISTS logo_url varchar(200);", + state_operations=[ + migrations.RemoveField( + model_name='systemsetting', + name='logo_url', + ), + ] ), migrations.AddField( model_name='systemsetting', @@ -64,4 +70,4 @@ class Migration(migrations.Migration): name='currency_symbol', field=models.CharField(default='OMR', max_length=10, verbose_name='Currency Symbol'), ), - ] \ No newline at end of file + ] diff --git a/core/migrations/__pycache__/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.cpython-311.pyc b/core/migrations/__pycache__/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.cpython-311.pyc index f61ab89..a7957b2 100644 Binary files a/core/migrations/__pycache__/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.cpython-311.pyc and b/core/migrations/__pycache__/0003_remove_systemsetting_logo_url_systemsetting_logo_and_more.cpython-311.pyc differ diff --git a/manage.py b/manage.py index b9c0926..7dcd3e8 100755 --- a/manage.py +++ b/manage.py @@ -2,36 +2,28 @@ """Django's command-line utility for administrative tasks.""" import os import sys -import traceback +from pathlib import Path def main(): """Run administrative tasks.""" + try: + from dotenv import load_dotenv + env_path = Path(__file__).resolve().parent.parent / '.env' + if env_path.exists(): + load_dotenv(env_path) + except ImportError: + pass + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: - try: - with open('startup_error.log', 'w') as f: - f.write("ImportError:\n") - f.write(traceback.format_exc()) - except: - pass raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc - - try: - execute_from_command_line(sys.argv) - except Exception: - try: - with open('startup_error.log', 'w') as f: - f.write("RuntimeError:\n") - f.write(traceback.format_exc()) - except: - pass - raise + execute_from_command_line(sys.argv) if __name__ == '__main__': - main() + main() \ No newline at end of file diff --git a/manage_trace.txt b/manage_trace.txt new file mode 100644 index 0000000..985eaca --- /dev/null +++ b/manage_trace.txt @@ -0,0 +1 @@ +Manage.py started diff --git a/requirements.txt b/requirements.txt index d705038..5ea193d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,6 @@ -Django==5.2.7 +Django>=5.0,<6.0 mysqlclient==2.2.7 python-dotenv==1.1.1 -pyzk==0.9 gunicorn==21.2.0 -whitenoise==6.6.0 requests -openpyxl \ No newline at end of file +openpyxl diff --git a/settings_trace.txt b/settings_trace.txt new file mode 100644 index 0000000..944488a --- /dev/null +++ b/settings_trace.txt @@ -0,0 +1 @@ +Settings loaded diff --git a/startup_status.txt b/startup_status.txt new file mode 100644 index 0000000..ecbe128 --- /dev/null +++ b/startup_status.txt @@ -0,0 +1,18 @@ +[2026-02-09T07:28:37.599243] Starting manage.py... +[2026-02-09T07:28:37.599461] Args: ['manage.py', 'runserver', '0.0.0.0:8000'] +[2026-02-09T07:28:37.653416] Loaded .env +[2026-02-09T07:28:38.658262] Django setup complete. +[2026-02-09T07:28:38.658403] Executing command line... +[2026-02-09T07:28:46.088684] SystemExit caught: 3 +[2026-02-09T07:28:46.362448] Starting manage.py... +[2026-02-09T07:28:46.362618] Args: ['manage.py', 'runserver', '0.0.0.0:8000'] +[2026-02-09T07:28:46.390956] Loaded .env +[2026-02-09T07:28:46.717591] Django setup complete. +[2026-02-09T07:28:46.717749] Executing command line... +[2026-02-09T07:42:35.563432] SystemExit caught: 3 +[2026-02-09T07:42:36.571344] Starting manage.py... +[2026-02-09T07:42:36.571557] Args: ['manage.py', 'runserver', '0.0.0.0:8000'] +[2026-02-09T07:42:36.626917] Loaded .env +[2026-02-09T07:42:37.207600] Django setup complete. +[2026-02-09T07:42:37.207759] Executing command line... +[2026-02-09T07:42:38.535239] SystemExit caught: 3 diff --git a/wsgi_crash.txt b/wsgi_crash.txt new file mode 100644 index 0000000..4143b0d --- /dev/null +++ b/wsgi_crash.txt @@ -0,0 +1,30 @@ +WSGI Crash: No module named 'whitenoise' +Traceback (most recent call last): + File "/home/ubuntu/executor/workspace/config/wsgi.py", line 19, in + application = get_wsgi_application() + ^^^^^^^^^^^^^^^^^^^^^^ + File "/home/ubuntu/.local/lib/python3.11/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application + return WSGIHandler() + ^^^^^^^^^^^^^ + File "/home/ubuntu/.local/lib/python3.11/site-packages/django/core/handlers/wsgi.py", line 118, in __init__ + self.load_middleware() + File "/home/ubuntu/.local/lib/python3.11/site-packages/django/core/handlers/base.py", line 40, in load_middleware + middleware = import_string(middleware_path) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/home/ubuntu/.local/lib/python3.11/site-packages/django/utils/module_loading.py", line 30, in import_string + return cached_import(module_path, class_name) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/home/ubuntu/.local/lib/python3.11/site-packages/django/utils/module_loading.py", line 15, in cached_import + module = import_module(module_path) + ^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module + return _bootstrap._gcd_import(name[level:], package, level) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "", line 1206, in _gcd_import + File "", line 1178, in _find_and_load + File "", line 1128, in _find_and_load_unlocked + File "", line 241, in _call_with_frames_removed + File "", line 1206, in _gcd_import + File "", line 1178, in _find_and_load + File "", line 1142, in _find_and_load_unlocked +ModuleNotFoundError: No module named 'whitenoise' diff --git a/wsgi_status.txt b/wsgi_status.txt new file mode 100644 index 0000000..b5be6c0 --- /dev/null +++ b/wsgi_status.txt @@ -0,0 +1,9 @@ +[2026-02-09T07:28:46.937704] WSGI module loading... +[2026-02-09T07:28:46.948377] WSGI loaded .env +[2026-02-09T07:28:46.952251] WSGI application created successfully. +[2026-02-09T07:42:37.533157] WSGI module loading... +[2026-02-09T07:42:37.541628] WSGI loaded .env +[2026-02-09T07:42:37.544967] WSGI application created successfully. +[2026-02-09T07:42:39.272623] WSGI module loading... +[2026-02-09T07:42:39.280940] WSGI loaded .env +[2026-02-09T07:42:39.283449] WSGI application created successfully. diff --git a/wsgi_trace.txt b/wsgi_trace.txt new file mode 100644 index 0000000..3f6e51a --- /dev/null +++ b/wsgi_trace.txt @@ -0,0 +1 @@ +WSGI loaded