Introduce command-line interface and supporting modules for project initialization. - New Features: - Add `cli.py` with Typer commands `secret` and `app` - Implement custom exception hierarchy in `utils/exceptions.py` - Provide secret key generation utilities in `utils/secretkey.py` - Add name validation logic in `utils/validators.py` - Initialize package with empty `__init__.py` - Enhancements: - Update `pyproject.toml` to include new modules and console script entry points - Bug Fixes: - (none)
104 lines
2.4 KiB
Plaintext
104 lines
2.4 KiB
Plaintext
# @IF url_type == 'project'
|
|
"""generated with djinit"""
|
|
|
|
from django.contrib import admin
|
|
from django.urls import path
|
|
# @IF include_api or include_apps
|
|
from django.urls import include
|
|
# @ENDIF
|
|
# @IF include_api
|
|
from django.conf import settings
|
|
from drf_spectacular.views import (
|
|
SpectacularAPIView,
|
|
SpectacularSwaggerView,
|
|
)
|
|
from rest_framework_simplejwt.views import (
|
|
TokenObtainPairView,
|
|
TokenRefreshView,
|
|
TokenBlacklistView,
|
|
)
|
|
# @ENDIF
|
|
|
|
urlpatterns = [
|
|
path("admin/", admin.site.urls),
|
|
# @IF include_api
|
|
# JWT tokens
|
|
path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
|
|
path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
|
|
path("token/blacklist/", TokenBlacklistView.as_view(), name="token_blacklist"),
|
|
# @ENDIF
|
|
# @IF include_api and comment_out_api_url
|
|
# path("api/", include("[[ api_module ]].urls")),
|
|
# @ENDIF
|
|
# @IF include_api and not comment_out_api_url
|
|
path("api/", include("[[ api_module ]].urls")),
|
|
# @ENDIF
|
|
# @IF include_apps
|
|
# App URLs
|
|
# @LOOP app in app_names
|
|
path("", include("[[ app ]].urls")),
|
|
# @ENDLOOP
|
|
# @ENDIF
|
|
]
|
|
# @IF include_api
|
|
|
|
# Don't show schema in production
|
|
if settings.DEBUG:
|
|
urlpatterns += [
|
|
path("schema/", SpectacularAPIView.as_view(), name="schema"),
|
|
path("docs/", SpectacularSwaggerView.as_view(url_name="schema")),
|
|
]
|
|
# @ENDIF
|
|
# @ENDIF
|
|
# @IF url_type == 'api_root'
|
|
from django.urls import include, path
|
|
|
|
app_name = "[[ app_name ]]"
|
|
|
|
urlpatterns = [
|
|
path("[[ version ]]/", include("[[ api_module ]].[[ version ]].urls")),
|
|
]
|
|
# @ENDIF
|
|
# @IF url_type == 'api_version'
|
|
from django.urls import include, path
|
|
|
|
app_name = "[[ app_name ]]"
|
|
|
|
urlpatterns = [
|
|
# @LOOP app in app_list
|
|
path("[[ app ]]/", include("[[ app_module ]].[[ app ]].urls")),
|
|
# @ENDLOOP
|
|
]
|
|
# @ENDIF
|
|
# @IF url_type == 'drf_router'
|
|
from rest_framework.routers import DefaultRouter
|
|
# @IF has_viewset
|
|
from [[ app_module ]].views.[[ view_file ]] import [[ viewset_name ]]
|
|
# @ENDIF
|
|
# @IF has_app_name
|
|
|
|
app_name = "[[ app_name ]]"
|
|
# @ENDIF
|
|
|
|
router = DefaultRouter()
|
|
# @IF has_viewset
|
|
router.register(r"[[ router_prefix ]]", [[ viewset_name ]], basename="[[ basename ]]")
|
|
# @ENDIF
|
|
|
|
urlpatterns = [
|
|
# @IF has_include
|
|
path("", include(router.urls)),
|
|
# @ENDIF
|
|
]
|
|
# @IF not has_include
|
|
urlpatterns = router.urls
|
|
# @ENDIF
|
|
# @ENDIF
|
|
# @IF url_type == 'component'
|
|
from django.urls import path
|
|
|
|
urlpatterns = [
|
|
# Add your URL patterns here
|
|
]
|
|
# @ENDIF
|