Skip to content

Commit 92feb53

Browse files
committed
url version dynamic
1 parent 79d4a78 commit 92feb53

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

django_petra/core.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ def bind_modules_urls():
5454
if module_urls_path.exists():
5555
# Construct the import path for the module's urls
5656
module_urls = f'modules.{module_name}.urls'
57+
58+
# Import the module to get its version
59+
urls_module = import_module(module_urls)
60+
# Get version from module, default to 'v1' if not specified
61+
version = getattr(urls_module, 'API_VERSION', 'v1')
5762

5863
# Append a path to urlpatterns, including the module's urls
59-
urlpatterns.append(path(f'api/v1/{module_name}/', include((module_urls, module_name))))
64+
urlpatterns.append(path(f'api/{version}/{module_name}/', include((module_urls, module_name))))
6065

6166
# Return the urlpatterns list
6267
return urlpatterns

0 commit comments

Comments
 (0)