from django.urls import path, re_path , include from rest_framework.routers import DefaultRouter, SimpleRouter from .views import BlogListAPIView, RelatedBlogsAPIView, BlogDetailBySlugAPIView from .views_admin import AdminBlogViewSet, AdminBlogContentViewSet, AdminBlogSeoViewSet app_name = 'blog' # --- Admin Router Setup --- admin_router = SimpleRouter() admin_router.register(r'blogs', AdminBlogViewSet, basename='admin-blogs') admin_router.register(r'contents', AdminBlogContentViewSet, basename='admin-blog-contents') admin_router.register(r'seo', AdminBlogSeoViewSet, basename='admin-blog-seo') # Hide admin viewsets from swagger for prefix, viewset, basename in admin_router.registry: viewset.swagger_schema = None urlpatterns = [ # Blog list with search and sort_by filters path('list/', BlogListAPIView.as_view(), name='blog-list'), # Related blogs for a specific blog ID path('related//', RelatedBlogsAPIView.as_view(), name='related-blogs'), # Blog detail by slug (using regex to support different languages) re_path(r'^detail/(?P[\w\-\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\u200C\u200D]+)/$', BlogDetailBySlugAPIView.as_view(), name='blog-detail'), path('admin/', include(admin_router.urls)), ]