mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 06:31:09 -05:00
feat: major project restructure - move Django to backend dir and fix critical imports
- Restructure project: moved Django backend to backend/ directory - Add frontend/ directory for future Next.js application - Add shared/ directory for common resources - Fix critical Django import errors: - Add missing sys.path modification for apps directory - Fix undefined CATEGORY_CHOICES imports in rides module - Fix media migration undefined references - Remove unused imports and f-strings without placeholders - Install missing django-environ dependency - Django server now runs without ModuleNotFoundError - Update .gitignore and README for new structure - Add pnpm workspace configuration for monorepo setup
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
"""
|
||||
ASGI config for thrillwiki project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.django.production")
|
||||
|
||||
application = get_asgi_application()
|
||||
@@ -1,237 +0,0 @@
|
||||
"""
|
||||
Django settings for thrillwiki project.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
SECRET_KEY = "django-insecure-=0)^0#h#k$0@$8$ys=^$0#h#k$0@$8$ys=^"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = ["https://beta.thrillwiki.com"]
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
# GeoDjango Settings
|
||||
GDAL_LIBRARY_PATH = "/opt/homebrew/lib/libgdal.dylib"
|
||||
GEOS_LIBRARY_PATH = "/opt/homebrew/lib/libgeos_c.dylib"
|
||||
|
||||
# Application definition
|
||||
INSTALLED_APPS = [
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.sites",
|
||||
"django.contrib.gis", # Add GeoDjango
|
||||
"pghistory", # Add django-pghistory
|
||||
"pgtrigger", # Required by django-pghistory
|
||||
"allauth",
|
||||
"allauth.account",
|
||||
"allauth.socialaccount",
|
||||
"allauth.socialaccount.providers.google",
|
||||
"allauth.socialaccount.providers.discord",
|
||||
"django_cleanup",
|
||||
"django_filters",
|
||||
"django_htmx",
|
||||
"whitenoise",
|
||||
"django_tailwind_cli",
|
||||
"autocomplete", # Django HTMX Autocomplete
|
||||
"debug_toolbar",
|
||||
"silk",
|
||||
"core",
|
||||
"accounts",
|
||||
"parks",
|
||||
"rides",
|
||||
"email_service",
|
||||
"media.apps.MediaConfig",
|
||||
"moderation",
|
||||
"location",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.cache.UpdateCacheMiddleware",
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
||||
"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",
|
||||
"core.middleware.PgHistoryContextMiddleware", # Add history context tracking
|
||||
"allauth.account.middleware.AccountMiddleware",
|
||||
"django.middleware.cache.FetchFromCacheMiddleware",
|
||||
"django_htmx.middleware.HtmxMiddleware",
|
||||
"core.middleware.PageViewMiddleware", # Add our page view tracking
|
||||
]
|
||||
|
||||
ROOT_URLCONF = "thrillwiki.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [os.path.join(BASE_DIR, "templates")],
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"moderation.context_processors.moderation_access",
|
||||
]
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = "thrillwiki.wsgi.application"
|
||||
|
||||
# Database
|
||||
|
||||
# For development, use PostgreSQL with PostGIS for GeoDjango features
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.contrib.gis.db.backends.postgis",
|
||||
"NAME": "thrillwiki",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "postgres",
|
||||
"HOST": "localhost",
|
||||
"PORT": "5432",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Cache settings
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
|
||||
"LOCATION": "unique-snowflake",
|
||||
"TIMEOUT": 300, # 5 minutes
|
||||
"OPTIONS": {"MAX_ENTRIES": 1000},
|
||||
}
|
||||
}
|
||||
|
||||
CACHE_MIDDLEWARE_SECONDS = 1 # 5 minutes
|
||||
CACHE_MIDDLEWARE_KEY_PREFIX = "thrillwiki"
|
||||
|
||||
# Password validation
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||
},
|
||||
]
|
||||
|
||||
# Internationalization
|
||||
LANGUAGE_CODE = "en-us"
|
||||
TIME_ZONE = "America/New_York"
|
||||
USE_I18N = True
|
||||
USE_TZ = True
|
||||
|
||||
# Static files (CSS JavaScript Images)
|
||||
STATIC_URL = "static/"
|
||||
STATICFILES_DIRS = [BASE_DIR / "static"]
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
||||
|
||||
# Media files
|
||||
MEDIA_URL = "/media/"
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
|
||||
# Default primary key field type
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
# Authentication settings
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
"django.contrib.auth.backends.ModelBackend",
|
||||
"allauth.account.auth_backends.AuthenticationBackend",
|
||||
]
|
||||
|
||||
# django-allauth settings
|
||||
SITE_ID = 1
|
||||
ACCOUNT_SIGNUP_FIELDS = ["email*", "username*", "password1*", "password2*"]
|
||||
ACCOUNT_LOGIN_METHODS = {"email", "username"}
|
||||
ACCOUNT_EMAIL_VERIFICATION = "optional"
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
ACCOUNT_LOGOUT_REDIRECT_URL = "/"
|
||||
|
||||
# Custom adapters
|
||||
ACCOUNT_ADAPTER = "accounts.adapters.CustomAccountAdapter"
|
||||
SOCIALACCOUNT_ADAPTER = "accounts.adapters.CustomSocialAccountAdapter"
|
||||
|
||||
# Social account settings
|
||||
# OAuth provider configuration moved to database SocialApp objects
|
||||
# This prevents conflicts between settings-based and database-based
|
||||
# configurations
|
||||
SOCIALACCOUNT_PROVIDERS = {
|
||||
"google": {
|
||||
"SCOPE": [
|
||||
"profile",
|
||||
"email",
|
||||
],
|
||||
"AUTH_PARAMS": {"access_type": "online"},
|
||||
},
|
||||
"discord": {
|
||||
"SCOPE": ["identify", "email"],
|
||||
"OAUTH_PKCE_ENABLED": True,
|
||||
},
|
||||
}
|
||||
|
||||
# Additional social account settings
|
||||
SOCIALACCOUNT_LOGIN_ON_GET = True
|
||||
SOCIALACCOUNT_AUTO_SIGNUP = False
|
||||
SOCIALACCOUNT_STORE_TOKENS = True
|
||||
|
||||
# Email settings
|
||||
EMAIL_BACKEND = "email_service.backends.ForwardEmailBackend"
|
||||
FORWARD_EMAIL_BASE_URL = "https://api.forwardemail.net"
|
||||
SERVER_EMAIL = "django_webmaster@thrillwiki.com"
|
||||
# Custom User Model
|
||||
AUTH_USER_MODEL = "accounts.User"
|
||||
|
||||
# Autocomplete configuration
|
||||
# Enable project-wide authentication requirement for autocomplete
|
||||
AUTOCOMPLETE_BLOCK_UNAUTHENTICATED = False
|
||||
|
||||
# Tailwind configuration
|
||||
# Tailwind configuration
|
||||
TAILWIND_CLI_CONFIG_FILE = os.path.join(BASE_DIR, "tailwind.config.js")
|
||||
TAILWIND_CLI_SRC_CSS = os.path.join(BASE_DIR, "static/css/src/input.css")
|
||||
TAILWIND_CLI_DIST_CSS = os.path.join(BASE_DIR, "static/css/tailwind.css")
|
||||
|
||||
# Cloudflare Turnstile settings
|
||||
TURNSTILE_SITE_KEY = "0x4AAAAAAAyqVp3RjccrC9Kz"
|
||||
TURNSTILE_SECRET_KEY = "0x4AAAAAAAyqVrQolYsrAFGJ39PXHJ_HQzY"
|
||||
TURNSTILE_VERIFY_URL = "https://challenges.cloudflare.com/turnstile/v0/siteverify"
|
||||
|
||||
# Test runner
|
||||
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
||||
|
||||
# Road Trip Service Settings
|
||||
ROADTRIP_CACHE_TIMEOUT = 3600 * 24 # 24 hours for geocoding
|
||||
ROADTRIP_ROUTE_CACHE_TIMEOUT = 3600 * 6 # 6 hours for routes
|
||||
ROADTRIP_MAX_REQUESTS_PER_SECOND = 1 # Respect OSM rate limits
|
||||
ROADTRIP_USER_AGENT = "ThrillWiki Road Trip Planner (https://thrillwiki.com)"
|
||||
ROADTRIP_REQUEST_TIMEOUT = 10 # seconds
|
||||
ROADTRIP_MAX_RETRIES = 3
|
||||
ROADTRIP_BACKOFF_FACTOR = 2
|
||||
|
||||
# Debug Toolbar Configuration
|
||||
INTERNAL_IPS = [
|
||||
"127.0.0.1",
|
||||
"localhost",
|
||||
]
|
||||
@@ -1,192 +0,0 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.views.static import serve
|
||||
from accounts import views as accounts_views
|
||||
from django.views.generic import TemplateView
|
||||
from .views import HomeView
|
||||
from . import views
|
||||
import os
|
||||
|
||||
# Import API documentation views
|
||||
try:
|
||||
from drf_spectacular.views import (
|
||||
SpectacularAPIView,
|
||||
SpectacularSwaggerView,
|
||||
SpectacularRedocView,
|
||||
)
|
||||
|
||||
HAS_SPECTACULAR = True
|
||||
except ImportError:
|
||||
HAS_SPECTACULAR = False
|
||||
|
||||
# Import enhanced health check views
|
||||
try:
|
||||
from core.views.health_views import (
|
||||
HealthCheckAPIView,
|
||||
PerformanceMetricsView,
|
||||
SimpleHealthView,
|
||||
)
|
||||
|
||||
HAS_HEALTH_VIEWS = True
|
||||
except ImportError:
|
||||
HAS_HEALTH_VIEWS = False
|
||||
|
||||
# Import autocomplete URLs
|
||||
try:
|
||||
from autocomplete import urls as autocomplete_urls
|
||||
|
||||
HAS_AUTOCOMPLETE = True
|
||||
except ImportError:
|
||||
HAS_AUTOCOMPLETE = False
|
||||
|
||||
# Build URL patterns list dynamically
|
||||
urlpatterns = [
|
||||
path("admin/", admin.site.urls),
|
||||
# Main app URLs
|
||||
path("", HomeView.as_view(), name="home"),
|
||||
# Health Check URLs
|
||||
path("health/", include("health_check.urls")),
|
||||
# API URLs (before app URLs to avoid conflicts)
|
||||
path("api/v1/", include("parks.api.urls", namespace="parks_api")),
|
||||
path("api/v1/", include("rides.api.urls", namespace="rides_api")),
|
||||
path(
|
||||
"api/v1/map/", include("core.urls.map_urls", namespace="map_api")
|
||||
), # Map API URLs
|
||||
# Parks and Rides URLs
|
||||
path("parks/", include("parks.urls", namespace="parks")),
|
||||
# Global rides URLs
|
||||
path("rides/", include("rides.urls", namespace="rides")),
|
||||
# Operators URLs
|
||||
path("operators/", include("parks.urls", namespace="operators")),
|
||||
# Other URLs
|
||||
path("photos/", include("media.urls", namespace="photos")),
|
||||
# Add photos URLs
|
||||
path("search/", include("core.urls.search", namespace="search")),
|
||||
path("maps/", include("core.urls.maps", namespace="maps")),
|
||||
# Map HTML views
|
||||
path(
|
||||
"terms/",
|
||||
TemplateView.as_view(template_name="pages/terms.html"),
|
||||
name="terms",
|
||||
),
|
||||
path(
|
||||
"privacy/",
|
||||
TemplateView.as_view(template_name="pages/privacy.html"),
|
||||
name="privacy",
|
||||
),
|
||||
# Custom authentication URLs first (to override allauth defaults)
|
||||
path("accounts/", include("accounts.urls")),
|
||||
# Default allauth URLs (for social auth and other features)
|
||||
path("accounts/", include("allauth.urls")),
|
||||
path(
|
||||
"accounts/email-required/",
|
||||
accounts_views.email_required,
|
||||
name="email_required",
|
||||
),
|
||||
# User profile URLs
|
||||
path(
|
||||
"user/<str:username>/",
|
||||
accounts_views.ProfileView.as_view(),
|
||||
name="user_profile",
|
||||
),
|
||||
path(
|
||||
"profile/<str:username>/",
|
||||
accounts_views.ProfileView.as_view(),
|
||||
name="profile",
|
||||
),
|
||||
path("settings/", accounts_views.SettingsView.as_view(), name="settings"),
|
||||
# Redirect /user/ to the user's profile if logged in
|
||||
path("user/", accounts_views.user_redirect_view, name="user_redirect"),
|
||||
# Moderation URLs - placed after other URLs but before static/media serving
|
||||
path("moderation/", include("moderation.urls", namespace="moderation")),
|
||||
path(
|
||||
"env-settings/",
|
||||
views.environment_and_settings_view,
|
||||
name="environment_and_settings",
|
||||
),
|
||||
]
|
||||
|
||||
# Add autocomplete URLs if available
|
||||
if HAS_AUTOCOMPLETE:
|
||||
urlpatterns.insert(2, path("ac/", include((autocomplete_urls[0], autocomplete_urls[1]), namespace=autocomplete_urls[2])))
|
||||
|
||||
# Add API Documentation URLs if available
|
||||
if HAS_SPECTACULAR:
|
||||
urlpatterns.extend(
|
||||
[
|
||||
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
|
||||
path(
|
||||
"api/docs/",
|
||||
SpectacularSwaggerView.as_view(url_name="schema"),
|
||||
name="swagger-ui",
|
||||
),
|
||||
path(
|
||||
"api/redoc/",
|
||||
SpectacularRedocView.as_view(url_name="schema"),
|
||||
name="redoc",
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# Add enhanced health check URLs if available
|
||||
if HAS_HEALTH_VIEWS:
|
||||
urlpatterns.extend(
|
||||
[
|
||||
path("health/api/", HealthCheckAPIView.as_view(), name="health-api"),
|
||||
path(
|
||||
"health/simple/",
|
||||
SimpleHealthView.as_view(),
|
||||
name="health-simple",
|
||||
),
|
||||
path(
|
||||
"health/metrics/",
|
||||
PerformanceMetricsView.as_view(),
|
||||
name="health-metrics",
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# Serve static files in development
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
# Development monitoring URLs
|
||||
try:
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns = [
|
||||
path("__debug__/", include(debug_toolbar.urls)),
|
||||
] + urlpatterns
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
pass
|
||||
|
||||
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Serve test coverage reports in development
|
||||
coverage_dir = os.path.join(settings.BASE_DIR, "tests", "coverage_html")
|
||||
if os.path.exists(coverage_dir):
|
||||
urlpatterns += [
|
||||
path(
|
||||
"coverage/",
|
||||
serve,
|
||||
{"document_root": coverage_dir, "path": "index.html"},
|
||||
),
|
||||
path(
|
||||
"coverage/<path:path>",
|
||||
serve,
|
||||
{
|
||||
"document_root": coverage_dir,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
handler404 = "thrillwiki.views.handler404"
|
||||
handler500 = "thrillwiki.views.handler500"
|
||||
@@ -1,158 +0,0 @@
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import TemplateView
|
||||
from django.db.models import Q
|
||||
from django.core.cache import cache
|
||||
from parks.models import Park, Company
|
||||
from rides.models import Ride
|
||||
from core.analytics import PageView
|
||||
from django.conf import settings
|
||||
import os
|
||||
import secrets
|
||||
|
||||
|
||||
def handler404(request, exception):
|
||||
return render(request, "404.html", status=404)
|
||||
|
||||
|
||||
def handler500(request):
|
||||
return render(request, "500.html", status=500)
|
||||
|
||||
|
||||
class HomeView(TemplateView):
|
||||
template_name = "home.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
# Get stats
|
||||
context["stats"] = {
|
||||
"total_parks": Park.objects.count(),
|
||||
"ride_count": Ride.objects.count(),
|
||||
"coaster_count": Ride.objects.filter(category="RC").count(),
|
||||
}
|
||||
|
||||
# Try to get trending items from cache first
|
||||
trending_parks = cache.get("trending_parks")
|
||||
trending_rides = cache.get("trending_rides")
|
||||
|
||||
# If not in cache, get them directly and cache them
|
||||
if trending_parks is None:
|
||||
try:
|
||||
trending_parks = list(
|
||||
PageView.get_trending_items(Park, hours=24, limit=10)
|
||||
)
|
||||
if trending_parks:
|
||||
cache.set(
|
||||
"trending_parks", trending_parks, 3600
|
||||
) # Cache for 1 hour
|
||||
else:
|
||||
# Fallback to highest rated parks if no trending data
|
||||
trending_parks = Park.objects.exclude(
|
||||
average_rating__isnull=True
|
||||
).order_by("-average_rating")[:10]
|
||||
except Exception:
|
||||
# Fallback to highest rated parks if trending calculation fails
|
||||
trending_parks = Park.objects.exclude(
|
||||
average_rating__isnull=True
|
||||
).order_by("-average_rating")[:10]
|
||||
|
||||
if trending_rides is None:
|
||||
try:
|
||||
trending_rides = list(
|
||||
PageView.get_trending_items(Ride, hours=24, limit=10)
|
||||
)
|
||||
if trending_rides:
|
||||
cache.set(
|
||||
"trending_rides", trending_rides, 3600
|
||||
) # Cache for 1 hour
|
||||
else:
|
||||
# Fallback to highest rated rides if no trending data
|
||||
trending_rides = Ride.objects.exclude(
|
||||
average_rating__isnull=True
|
||||
).order_by("-average_rating")[:10]
|
||||
except Exception:
|
||||
# Fallback to highest rated rides if trending calculation fails
|
||||
trending_rides = Ride.objects.exclude(
|
||||
average_rating__isnull=True
|
||||
).order_by("-average_rating")[:10]
|
||||
|
||||
# Get highest rated items (mix of parks and rides)
|
||||
highest_rated_parks = list(
|
||||
Park.objects.exclude(average_rating__isnull=True).order_by(
|
||||
"-average_rating"
|
||||
)[:20]
|
||||
) # Get more items to randomly select from
|
||||
|
||||
highest_rated_rides = list(
|
||||
Ride.objects.exclude(average_rating__isnull=True).order_by(
|
||||
"-average_rating"
|
||||
)[:20]
|
||||
) # Get more items to randomly select from
|
||||
|
||||
# Combine and shuffle highest rated items
|
||||
all_highest_rated = highest_rated_parks + highest_rated_rides
|
||||
secrets.SystemRandom().shuffle(all_highest_rated)
|
||||
|
||||
# Keep the same context variable names for template compatibility
|
||||
context["popular_parks"] = trending_parks
|
||||
context["popular_rides"] = trending_rides
|
||||
context["highest_rated"] = all_highest_rated[
|
||||
:10
|
||||
] # Take first 10 after shuffling
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class SearchView(TemplateView):
|
||||
template_name = "search_results.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
if query := self.request.GET.get("q", "").strip():
|
||||
# Search parks
|
||||
context["parks"] = (
|
||||
Park.objects.filter(
|
||||
Q(name__icontains=query)
|
||||
| Q(location__icontains=query)
|
||||
| Q(description__icontains=query)
|
||||
)
|
||||
.select_related("operating_company")
|
||||
.prefetch_related("photos")[:10]
|
||||
)
|
||||
|
||||
# Search rides
|
||||
context["rides"] = (
|
||||
Ride.objects.filter(
|
||||
Q(name__icontains=query)
|
||||
| Q(description__icontains=query)
|
||||
| Q(manufacturer__name__icontains=query)
|
||||
)
|
||||
.select_related("park", "coaster_stats")
|
||||
.prefetch_related("photos")[:10]
|
||||
)
|
||||
|
||||
# Search companies
|
||||
context["companies"] = Company.objects.filter(
|
||||
Q(name__icontains=query) | Q(description__icontains=query)
|
||||
).prefetch_related("operated_parks", "owned_parks")[:10]
|
||||
|
||||
return context
|
||||
|
||||
|
||||
def environment_and_settings_view(request):
|
||||
# Get all environment variables
|
||||
env_vars = dict(os.environ)
|
||||
|
||||
# Get all Django settings as a dictionary
|
||||
settings_vars = {
|
||||
setting: getattr(settings, setting)
|
||||
for setting in dir(settings)
|
||||
if setting.isupper()
|
||||
}
|
||||
|
||||
return render(
|
||||
request,
|
||||
"environment_and_settings.html",
|
||||
{"env_vars": env_vars, "settings_vars": settings_vars},
|
||||
)
|
||||
@@ -1,16 +0,0 @@
|
||||
"""
|
||||
WSGI config for thrillwiki 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.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.django.production")
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user