Files
octopus/myproject/myproject/urls.py
Andrey Smakotin 483f150e7a feat(static): improve static files handling and permissions in Docker
- Add script to set correct permissions on static files after collectstatic
- Introduce collectstatic command in entrypoint with permission fixing
- Add WhiteNoise middleware for efficient static file serving without DB access
- Configure WhiteNoise static files storage backend in settings
- Set STATIC_ROOT path properly for Docker container environment
- Add fallback static files serving in Django urls for production without nginx
- Enhance inventory_detail.html scripts to log errors if JS files or components fail to load
- Add whitenoise package to requirements for static file serving support
2025-12-22 20:45:52 +03:00

54 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
"""
URL configuration for TENANT schemas (shop1.inventory.by, shop2.inventory.by, etc.).
This is used for individual shop subdomains where shop owners manage their business.
"""
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
from . import views
urlpatterns = [
path('_nested_admin/', include('nested_admin.urls')), # Для nested admin
path('admin/', admin.site.urls), # Админка для владельца магазина (доступна на поддомене)
# Web interface for shop owners
path('', views.index, name='index'), # Главная страница
path('accounts/', include('accounts.urls')), # Управление аккаунтом
path('roles/', include('user_roles.urls')), # Управление ролями пользователей
path('products/', include('products.urls')), # Управление товарами
path('customers/', include('customers.urls')), # Управление клиентами
path('inventory/', include('inventory.urls')), # Управление складом
path('orders/', include('orders.urls')), # Управление заказами
path('pos/', include('pos.urls')), # POS Terminal
]
# Serve media files during development
# Serve media files during 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 (только в DEBUG режиме)
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,
}),
]