urls.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from django.conf import settings
  2. from django.conf.urls.static import static
  3. from django.contrib import admin
  4. from django.urls import include, path
  5. from games import urls as games_urls
  6. from search import urls as search_urls
  7. from games.views import RecentGameList
  8. from games.api.views import (
  9. DeveloperViewSet,
  10. GameSystemViewSet,
  11. GameViewSet,
  12. GameCollectionViewSet,
  13. PublisherViewSet,
  14. GenreViewSet,
  15. )
  16. from rest_framework import routers
  17. router = routers.DefaultRouter()
  18. router.register(r"games", GameViewSet)
  19. router.register(r"publishers", PublisherViewSet)
  20. router.register(r"developers", DeveloperViewSet)
  21. router.register(r"genre", GenreViewSet)
  22. router.register(r"game-systems", GameSystemViewSet)
  23. router.register(r"game-collections", GameCollectionViewSet)
  24. urlpatterns = [
  25. path("accounts/", include("allauth.urls")),
  26. path("admin/", admin.site.urls),
  27. path("api-auth/", include("rest_framework.urls")),
  28. path("api/v1/", include(router.urls)),
  29. path("search/", include(search_urls, namespace="search")),
  30. path("games/", include(games_urls, namespace="games")),
  31. path("", RecentGameList.as_view(), name="home"),
  32. ]
  33. if settings.DEBUG:
  34. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  35. urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)