mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 06:11:07 -05:00
Add management command to seed comprehensive sample data for ThrillWiki application
- Implemented cleanup of existing sample data to avoid conflicts. - Created functions to generate companies, parks, rides, park areas, and reviews. - Ensured proper relationships between models during data creation. - Added logging for better tracking of data seeding process. - Included checks for required database tables before seeding.
This commit is contained in:
@@ -43,6 +43,8 @@ INSTALLED_APPS = [
|
||||
"whitenoise",
|
||||
"django_tailwind_cli",
|
||||
"autocomplete", # Django HTMX Autocomplete
|
||||
"debug_toolbar",
|
||||
"silk",
|
||||
"core",
|
||||
"accounts",
|
||||
"parks",
|
||||
@@ -57,6 +59,7 @@ 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",
|
||||
@@ -93,21 +96,19 @@ WSGI_APPLICATION = "thrillwiki.wsgi.application"
|
||||
|
||||
# Database
|
||||
|
||||
# Parse database URL but force PostGIS engine
|
||||
db_config = dj_database_url.config(
|
||||
default="[DATABASE-URL-REMOVED]
|
||||
conn_max_age=600,
|
||||
conn_health_checks=True,
|
||||
)
|
||||
|
||||
# Force PostGIS engine - override any parsed engine
|
||||
# For development, use PostgreSQL with PostGIS for GeoDjango features
|
||||
DATABASES = {
|
||||
"default": {
|
||||
**db_config,
|
||||
"ENGINE": "django.contrib.gis.db.backends.postgis",
|
||||
"NAME": "thrillwiki",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "postgres",
|
||||
"HOST": "localhost",
|
||||
"PORT": "5432",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Cache settings
|
||||
CACHES = {
|
||||
"default": {
|
||||
@@ -228,3 +229,9 @@ 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",
|
||||
]
|
||||
|
||||
@@ -30,27 +30,36 @@ urlpatterns = [
|
||||
path("", HomeView.as_view(), name="home"),
|
||||
# Autocomplete URLs (must be before other URLs)
|
||||
path("ac/", autocomplete_urls),
|
||||
|
||||
|
||||
# API Documentation URLs
|
||||
path("api/schema/", SpectacularAPIView.as_view(), name="schema") if HAS_SPECTACULAR else path("", lambda r: None),
|
||||
path("api/docs/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger-ui") if HAS_SPECTACULAR else path("", lambda r: None),
|
||||
path("api/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc") if HAS_SPECTACULAR else path("", lambda r: None),
|
||||
|
||||
path("api/schema/", SpectacularAPIView.as_view(),
|
||||
name="schema") if HAS_SPECTACULAR else path("", lambda r: None),
|
||||
path("api/docs/", SpectacularSwaggerView.as_view(url_name="schema"),
|
||||
name="swagger-ui") if HAS_SPECTACULAR else path("", lambda r: None),
|
||||
path("api/redoc/", SpectacularRedocView.as_view(url_name="schema"),
|
||||
name="redoc") if HAS_SPECTACULAR else path("", lambda r: None),
|
||||
|
||||
# Health Check URLs
|
||||
path("health/", include("health_check.urls")),
|
||||
path("health/api/", HealthCheckAPIView.as_view(), name="health-api") if HAS_HEALTH_VIEWS else path("", lambda r: None),
|
||||
path("health/simple/", SimpleHealthView.as_view(), name="health-simple") if HAS_HEALTH_VIEWS else path("", lambda r: None),
|
||||
path("health/metrics/", PerformanceMetricsView.as_view(), name="health-metrics") if HAS_HEALTH_VIEWS else path("", lambda r: None),
|
||||
|
||||
path("health/api/", HealthCheckAPIView.as_view(),
|
||||
name="health-api") if HAS_HEALTH_VIEWS else path("", lambda r: None),
|
||||
path("health/simple/", SimpleHealthView.as_view(),
|
||||
name="health-simple") if HAS_HEALTH_VIEWS else path("", lambda r: None),
|
||||
path("health/metrics/", PerformanceMetricsView.as_view(),
|
||||
name="health-metrics") if HAS_HEALTH_VIEWS else path("", lambda r: None),
|
||||
|
||||
# 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
|
||||
|
||||
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")),
|
||||
@@ -93,9 +102,11 @@ urlpatterns = [
|
||||
|
||||
# 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)
|
||||
|
||||
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
|
||||
@@ -104,13 +115,13 @@ if settings.DEBUG:
|
||||
] + urlpatterns
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
import silk
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user