"""
Django development settings for ThrillWiki project.
These settings are used during local development.
"""

from .base import *

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DEBUG', default=True)

ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['localhost', '127.0.0.1'])

# Development-specific apps
# INSTALLED_APPS += [
#     'silk',  # Profiling (optional, install django-silk if needed)
# ]

# MIDDLEWARE += [
#     'silk.middleware.SilkyMiddleware',
# ]

# Database - Use regular SQLite for local development
# PostGIS fields will work but without spatial query capabilities
# Full GIS features available in production with PostGIS
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

# Note: For full GIS capabilities in local dev, you would need:
# - SQLite compiled with extension support (pysqlite)
# - SpatiaLite extension installed
# For now, using regular SQLite is simpler for development

# GDAL library paths - Required even with regular SQLite when using GIS models
# For Homebrew on macOS (Apple Silicon)
GDAL_LIBRARY_PATH = env('GDAL_LIBRARY_PATH', default='/opt/homebrew/opt/gdal/lib/libgdal.dylib')
GEOS_LIBRARY_PATH = env('GEOS_LIBRARY_PATH', default='/opt/homebrew/opt/geos/lib/libgeos_c.dylib')

# Disable caching in development
CACHEOPS_ENABLED = False

# Email backend for development (console)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Django Debug Toolbar (optional, install if needed)
# INSTALLED_APPS += ['debug_toolbar']
# MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']
# INTERNAL_IPS = ['127.0.0.1']

# Celery - Use eager mode in development
CELERY_TASK_ALWAYS_EAGER = env.bool('CELERY_TASK_ALWAYS_EAGER', default=True)
CELERY_TASK_EAGER_PROPAGATES = True

# CORS - Allow all origins in development
CORS_ALLOW_ALL_ORIGINS = True

# Logging - More verbose in development
LOGGING['root']['level'] = 'DEBUG'
LOGGING['loggers']['django']['level'] = 'DEBUG'
LOGGING['loggers']['apps']['level'] = 'DEBUG'
