mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-20 01:59:50 +00:00
core django changes for new react ui
This commit is contained in:
parent
b2c323d61d
commit
1e4275ea7a
2 changed files with 29 additions and 28 deletions
|
|
@ -49,7 +49,10 @@ ROOT_URLCONF = 'dispatcharr.urls'
|
|||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [BASE_DIR / 'templates'],
|
||||
'DIRS': [
|
||||
os.path.join(BASE_DIR, 'frontend/build'),
|
||||
BASE_DIR / "templates"
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
|
|
@ -98,8 +101,14 @@ USE_I18N = True
|
|||
USE_TZ = True
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
STATICFILES_DIRS = [BASE_DIR / 'static']
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles' # Directory where static files will be collected
|
||||
|
||||
# Adjust STATICFILES_DIRS to include the paths to the directories that contain your static files.
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'frontend/build/static'), # React build static files
|
||||
BASE_DIR / 'static', # Django custom static files (if any)
|
||||
]
|
||||
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
AUTH_USER_MODEL = 'accounts.User'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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.generic import RedirectView
|
||||
from django.views.generic import TemplateView
|
||||
from rest_framework import permissions
|
||||
from drf_yasg.views import get_schema_view
|
||||
from drf_yasg import openapi
|
||||
|
|
@ -21,39 +21,31 @@ schema_view = get_schema_view(
|
|||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('', RedirectView.as_view(pattern_name='dashboard:dashboard'), name='home'),
|
||||
# API Routes
|
||||
path('api/', include(('apps.api.urls', 'api'), namespace='api')),
|
||||
|
||||
# Admin
|
||||
path('grappelli/', include('grappelli.urls')), # Grappelli admin
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
path('accounts/', include(('apps.accounts.urls', 'accounts'), namespace='accounts')),
|
||||
#path('streams/', include(('apps.streams.urls', 'streams'), namespace='streams')),
|
||||
#path('hdhr/', include(('apps.hdhr.urls', 'hdhr'), namespace='hdhr')),
|
||||
path('m3u/', include(('apps.m3u.urls', 'm3u'), namespace='m3u')),
|
||||
path('epg/', include(('apps.epg.urls', 'epg'), namespace='epg')),
|
||||
path('channels/', include(('apps.channels.urls', 'channels'), namespace='channels')),
|
||||
path('settings/', include(('core.urls', 'settings'), namespace='settings')),
|
||||
#path('backup/', include(('apps.backup.urls', 'backup'), namespace='backup')),
|
||||
path('dashboard/', include(('apps.dashboard.urls', 'dashboard'), namespace='dashboard')),
|
||||
path('output/', include('apps.output.urls', namespace='output')),
|
||||
|
||||
|
||||
# Swagger UI:
|
||||
# Swagger UI
|
||||
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
||||
|
||||
# ReDoc UI:
|
||||
|
||||
# ReDoc UI
|
||||
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
||||
|
||||
# Optionally, you can also serve the raw JSON:
|
||||
|
||||
# Optionally, serve the raw Swagger JSON
|
||||
path('swagger.json', schema_view.without_ui(cache_timeout=0), name='schema-json'),
|
||||
|
||||
# Catch-all route to serve React's index.html for non-API, non-admin paths
|
||||
path('', TemplateView.as_view(template_name='index.html')), # React entry point
|
||||
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
# Serve static files for development (React's JS, CSS, etc.)
|
||||
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.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
urlpatterns += [path('<path:unused_path>', TemplateView.as_view(template_name='index.html'))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue