fix(src/djinit/creators): add project_name to urls_context and urls.py template context
- Ensure project_name is passed when generating urls.py, preventing TemplateError. - Improves template rendering consistency for API route inclusion.
This commit is contained in:
1 file changed
+7
-2
@@ -117,7 +117,12 @@ class FileCreator(BaseService):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Helper to create urls.py, wsgi.py, and asgi.py."""
|
"""Helper to create urls.py, wsgi.py, and asgi.py."""
|
||||||
|
|
||||||
urls_context = {"url_type": "project", "api_module": api_module, "include_api": True}
|
urls_context = {
|
||||||
|
"url_type": "project",
|
||||||
|
"project_name": self.project_name,
|
||||||
|
"api_module": api_module,
|
||||||
|
"include_api": True,
|
||||||
|
}
|
||||||
if comment_out_api:
|
if comment_out_api:
|
||||||
urls_context["comment_out_api_url"] = True
|
urls_context["comment_out_api_url"] = True
|
||||||
|
|
||||||
@@ -303,7 +308,7 @@ class FileCreator(BaseService):
|
|||||||
CommonUtils.create_file_from_template(
|
CommonUtils.create_file_from_template(
|
||||||
project_urls_path,
|
project_urls_path,
|
||||||
"config/urls.py-tpl",
|
"config/urls.py-tpl",
|
||||||
{"url_type": "project", "api_module": "api", "include_api": True},
|
{"url_type": "project", "project_name": self.project_name, "api_module": "api", "include_api": True},
|
||||||
"Updated project urls.py to include API routes",
|
"Updated project urls.py to include API routes",
|
||||||
should_format=True,
|
should_format=True,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user