From 52dde7c95b1763971219d0fc42af88bbe86d8d08 Mon Sep 17 00:00:00 2001 From: poduck Date: Sun, 30 Nov 2025 21:02:24 -0500 Subject: [PATCH] Fix: Resolve Django settings import error and fix quick login API endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Settings Refactoring Fixes: - Add minimal LOGGING structure to base.py for multitenancy.py to extend - Restore LOGGING import in multitenancy.py - Add development LOGGING configuration to local.py - This allows multitenancy.py to extend LOGGING configuration properly Quick Login Fix: - Update frontend .env.development to use VITE_API_URL=http://localhost:8000 - Previous configuration tried to access api.lvh.me which failed due to django-tenants not recognizing that hostname - Using localhost:8000 directly bypasses subdomain routing and accesses the public schema where auth endpoints are available Both fixes restore full functionality: - Django now starts without import errors in local development - Quick login API calls now succeed and return authentication tokens - Frontend can authenticate users for development/testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/.env.development | 2 +- smoothschedule/config/settings/base.py | 15 +++++++++++++++ smoothschedule/config/settings/local.py | 11 +++++++++++ smoothschedule/config/settings/multitenancy.py | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend/.env.development b/frontend/.env.development index b2d8de4..c765184 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,2 +1,2 @@ VITE_DEV_MODE=true -VITE_API_URL=http://lvh.me:8000 +VITE_API_URL=http://localhost:8000 diff --git a/smoothschedule/config/settings/base.py b/smoothschedule/config/settings/base.py index 452191e..97192d0 100644 --- a/smoothschedule/config/settings/base.py +++ b/smoothschedule/config/settings/base.py @@ -224,6 +224,21 @@ MANAGERS = ADMINS # Force the `admin` sign in process to go through the `django-allauth` workflow DJANGO_ADMIN_FORCE_ALLAUTH = env.bool("DJANGO_ADMIN_FORCE_ALLAUTH", default=False) +# LOGGING - Base structure (extended by multitenancy.py, overridden by local.py/production.py) +# ------------------------------------------------------------------------------ +# Minimal structure here - actual handlers defined in environment-specific settings +LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "formatters": {}, + "handlers": { + "console": { + "level": "DEBUG", + "class": "logging.StreamHandler", + }, + }, +} + REDIS_URL = env("REDIS_URL", default="redis://redis:6379/0") REDIS_SSL = REDIS_URL.startswith("rediss://") diff --git a/smoothschedule/config/settings/local.py b/smoothschedule/config/settings/local.py index f3116b4..6f1b2db 100644 --- a/smoothschedule/config/settings/local.py +++ b/smoothschedule/config/settings/local.py @@ -114,5 +114,16 @@ INSTALLED_APPS += ["django_extensions"] # https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-eager-propagates CELERY_TASK_EAGER_PROPAGATES = True + +# LOGGING - Development +# ------------------------------------------------------------------------------ +# Extend the base LOGGING configuration with development settings +LOGGING["disable_existing_loggers"] = False +LOGGING["formatters"]["verbose"] = { + "format": "%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s", +} +LOGGING["handlers"]["console"]["formatter"] = "verbose" +LOGGING["root"] = {"level": "DEBUG", "handlers": ["console"]} + # Your stuff... # ------------------------------------------------------------------------------ diff --git a/smoothschedule/config/settings/multitenancy.py b/smoothschedule/config/settings/multitenancy.py index 628c9eb..0f8d7fd 100644 --- a/smoothschedule/config/settings/multitenancy.py +++ b/smoothschedule/config/settings/multitenancy.py @@ -4,7 +4,7 @@ This file extends base.py and adds django-tenants configuration """ from .base import * # noqa -from .base import INSTALLED_APPS, MIDDLEWARE, DATABASES, env +from .base import INSTALLED_APPS, MIDDLEWARE, DATABASES, LOGGING, env # ============================================================================= # MULTI-TENANCY CONFIGURATION (django-tenants)