Files
octopus/myproject/myproject/urls_public.py

46 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
"""
URL configuration for the PUBLIC schema (inventory.by domain).
This is the main domain where:
- Super admin can access admin panel
- Tenant registration is available
"""
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.urls import re_path
from django.views.static import serve
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('tenants.urls')), # Роуты для регистрации тенантов (/, /register/, /register/success/)
path('accounts/', include('accounts.urls')), # Роуты для установки пароля владельцами тенантов
]
# Serve media files in development
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
# Django Debug Toolbar (только если включено в настройках)
if getattr(settings, 'DEBUG_TOOLBAR_ENABLED', False):
import debug_toolbar
urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
]
else:
# Force serve media files in production (for NAS setup)
urlpatterns += [
re_path(r'^media/(?P<path>.*)$', serve, {
'document_root': settings.MEDIA_ROOT,
}),
]
# Fallback для статических файлов в production (если nginx не настроен или не может прочитать файлы)
urlpatterns += [
re_path(r'^static/(?P<path>.*)$', serve, {
'document_root': settings.STATIC_ROOT,
}),
]