Advertisement
themaleem

urls.py

Jul 17th, 2023 (edited)
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. """
  2. URL configuration for registrationapps project.
  3.  
  4. The `urlpatterns` list routes URLs to views. For more information please see:
  5. https://docs.djangoproject.com/en/4.2/topics/http/urls/
  6. Examples:
  7. Function views
  8. 1. Add an import: from my_app import views
  9. 2. Add a URL to urlpatterns: path('', views.home, name='home')
  10. Class-based views
  11. 1. Add an import: from other_app.views import Home
  12. 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
  13. Including another URLconf
  14. 1. Import the include() function: from django.urls import include, path
  15. 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
  16. """
  17.  
  18. from drf_yasg import openapi
  19. from django.contrib import admin
  20. from django.conf import settings
  21. from rest_framework import routers
  22. from django.urls import path, include
  23. from drf_yasg.views import get_schema_view
  24. from django.conf.urls.static import static
  25. from django.contrib.auth import views as auth_views
  26.  
  27.  
  28. from users import views as user_views
  29. from users import api_views as api_views
  30.  
  31.  
  32. router = routers.DefaultRouter()
  33. router.register(r"modules", api_views.ModuleViewSet)
  34. router.register(r"courses", api_views.CourseViewSet)
  35. router.register(r"students", api_views.StudentViewSet)
  36. router.register(r"registrations", api_views.RegistrationViewSet)
  37.  
  38. # API documentation URLs
  39. schema_view = get_schema_view(
  40. openapi.Info(
  41. title="Your API Title",
  42. default_version="v1",
  43. description="Your API Description",
  44. terms_of_service="https://www.example.com/terms/",
  45. contact=openapi.Contact(email="contact@example.com"),
  46. license=openapi.License(name="MIT License"),
  47. ),
  48. public=True,
  49. )
  50.  
  51.  
  52. urlpatterns = [
  53. path("admin/", admin.site.urls),
  54. path("", include("studentregistration.urls")),
  55. path("login/", user_views.login_view, name="login"),
  56. path("register", user_views.register, name="register"),
  57. path("student/profile/", user_views.profile, name="profile"),
  58. path("student/dashboard/", user_views.dashboard, name="dashboard"),
  59. path("logout/", user_views.CustomLogoutView.as_view(), name="logout"),
  60. path(
  61. "student/change-password/", user_views.change_password, name="change_password"
  62. ),
  63. path(
  64. "password_reset/",
  65. auth_views.PasswordResetView.as_view(template_name="users/password_reset.html"),
  66. name="password_reset",
  67. ),
  68. path(
  69. "password_reset/done/",
  70. auth_views.PasswordResetDoneView.as_view(
  71. template_name="users/password_reset_done.html"
  72. ),
  73. name="password_reset_done",
  74. ),
  75. path(
  76. "password_reset_confirm/<uidb64>/<token>/",
  77. auth_views.PasswordResetConfirmView.as_view(
  78. template_name="users/password_reset_confirm.html"
  79. ),
  80. name="password_reset_confirm",
  81. ),
  82. path(
  83. "password_reset_complete/",
  84. auth_views.PasswordResetCompleteView.as_view(
  85. template_name="users/password_reset_complete.html"
  86. ),
  87. name="password_reset_complete",
  88. ),
  89. path("api/", include(router.urls)),
  90. path(
  91. "api/student/<str:username>",
  92. api_views.StudentDetail.as_view(),
  93. name=api_views.StudentDetail.name,
  94. ),
  95. path(
  96. "api/module/<str:code>",
  97. api_views.ModuleDetail.as_view(),
  98. name=api_views.ModuleDetail.name,
  99. ),
  100. # path(
  101. # "api/course/<str:name>",
  102. # CourseDetail.as_view(),
  103. # name=CourseDetail.name,
  104. # ),
  105. path(
  106. "swagger/",
  107. schema_view.with_ui("swagger", cache_timeout=0),
  108. name="schema-swagger-ui",
  109. ),
  110. path("redoc/", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
  111. ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  112.  
  113.  
  114. handler404 = "studentregistration.views.error_404"
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement