version 16

This commit is contained in:
Flatlogic Bot 2026-03-13 02:27:56 +00:00
parent 1ad6b959ed
commit 658ba85e2b
6 changed files with 18 additions and 11 deletions

View File

@ -76,7 +76,7 @@ ROOT_URLCONF = 'config.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [BASE_DIR.parent / 'frontend' / 'dist'],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@ -151,8 +151,8 @@ STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_DIRS = [ STATICFILES_DIRS = [
BASE_DIR / 'static', BASE_DIR / 'static',
BASE_DIR / 'assets', BASE_DIR.parent / 'frontend' / 'dist',
BASE_DIR / 'node_modules', BASE_DIR.parent / 'frontend' / 'dist' / 'assets',
] ]
# Email # Email

View File

@ -1,12 +1,13 @@
from django.urls import path, include from django.urls import path, include, re_path
from rest_framework.routers import DefaultRouter from rest_framework.routers import DefaultRouter
from .views import SellerViewSet, ProductViewSet, CategoryViewSet from .views import SellerViewSet, ProductViewSet, CategoryViewSet, serve_frontend
router = DefaultRouter() router = DefaultRouter()
router.register(r'categories', CategoryViewSet) router.register(r'api/categories', CategoryViewSet)
router.register(r'sellers', SellerViewSet) router.register(r'api/sellers', SellerViewSet)
router.register(r'products', ProductViewSet) router.register(r'api/products', ProductViewSet)
urlpatterns = [ urlpatterns = [
path('', include(router.urls)), path('', include(router.urls)),
re_path(r'^(?!api/|admin/).*$', serve_frontend, name='serve_frontend'),
] ]

View File

@ -1,7 +1,13 @@
import os
from django.shortcuts import render
from django.conf import settings
from rest_framework import viewsets from rest_framework import viewsets
from .models import Seller, Product, Category from .models import Seller, Product, Category
from .serializers import SellerSerializer, ProductSerializer, CategorySerializer from .serializers import SellerSerializer, ProductSerializer, CategorySerializer
def serve_frontend(request, path=''):
return render(request, 'index.html')
class CategoryViewSet(viewsets.ModelViewSet): class CategoryViewSet(viewsets.ModelViewSet):
queryset = Category.objects.all() queryset = Category.objects.all()
serializer_class = CategorySerializer serializer_class = CategorySerializer