version 16
This commit is contained in:
parent
1ad6b959ed
commit
658ba85e2b
Binary file not shown.
@ -76,7 +76,7 @@ ROOT_URLCONF = 'config.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': [BASE_DIR.parent / 'frontend' / 'dist'],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@ -151,8 +151,8 @@ STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / 'static',
|
||||
BASE_DIR / 'assets',
|
||||
BASE_DIR / 'node_modules',
|
||||
BASE_DIR.parent / 'frontend' / 'dist',
|
||||
BASE_DIR.parent / 'frontend' / 'dist' / 'assets',
|
||||
]
|
||||
|
||||
# Email
|
||||
@ -196,4 +196,4 @@ REST_FRAMEWORK = {
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
'rest_framework.authentication.BasicAuthentication',
|
||||
],
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@ -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 .views import SellerViewSet, ProductViewSet, CategoryViewSet
|
||||
from .views import SellerViewSet, ProductViewSet, CategoryViewSet, serve_frontend
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'categories', CategoryViewSet)
|
||||
router.register(r'sellers', SellerViewSet)
|
||||
router.register(r'products', ProductViewSet)
|
||||
router.register(r'api/categories', CategoryViewSet)
|
||||
router.register(r'api/sellers', SellerViewSet)
|
||||
router.register(r'api/products', ProductViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
]
|
||||
re_path(r'^(?!api/|admin/).*$', serve_frontend, name='serve_frontend'),
|
||||
]
|
||||
@ -1,7 +1,13 @@
|
||||
import os
|
||||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
from rest_framework import viewsets
|
||||
from .models import Seller, Product, Category
|
||||
from .serializers import SellerSerializer, ProductSerializer, CategorySerializer
|
||||
|
||||
def serve_frontend(request, path=''):
|
||||
return render(request, 'index.html')
|
||||
|
||||
class CategoryViewSet(viewsets.ModelViewSet):
|
||||
queryset = Category.objects.all()
|
||||
serializer_class = CategorySerializer
|
||||
@ -12,4 +18,4 @@ class SellerViewSet(viewsets.ModelViewSet):
|
||||
|
||||
class ProductViewSet(viewsets.ModelViewSet):
|
||||
queryset = Product.objects.all()
|
||||
serializer_class = ProductSerializer
|
||||
serializer_class = ProductSerializer
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user