From e5f77143bf2e8eea4b391c71c3cc5a7901bd0dbc Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 20 Apr 2026 14:27:59 +0545 Subject: [PATCH] feat(src/djinit/utils): add get_full_app_config_path static method to compute full AppConfig pathAdd a static method `get_full_app_config_path` that builds the full path to an AppConfig class, handling nested app structures and module resolution. Improves reliability of AppConfig path calculation. - New Features - Added `get_full_app_config_path` method to generate full AppConfig paths. - Enhancements - Centralized AppConfig path calculation logic using existing `calculate_app_module_path`. - Bug Fixes - None --- src/djinit/utils/common.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/djinit/utils/common.py b/src/djinit/utils/common.py index ebd3f92..bc77140 100644 --- a/src/djinit/utils/common.py +++ b/src/djinit/utils/common.py @@ -250,6 +250,18 @@ class CommonUtils(BaseUtils): def calculate_app_module_path(app_name: str, nested: bool, nested_dir: str | None) -> str: return f"{nested_dir}.{app_name}" if nested and nested_dir else app_name + @staticmethod + def get_full_app_config_path(app_name: str, nested: bool, nested_dir: str | None) -> str: + """Get the full path to the AppConfig class. + Example: users -> users.apps.UsersConfig + Example: (nested) apps.users -> apps.users.apps.UsersConfig + """ + module_path = CommonUtils.calculate_app_module_path(app_name, nested, nested_dir) + # Handle cases where app_name might be a module path already + short_name = app_name.split(".")[-1] + config_name = short_name.title().replace("_", "") + "Config" + return f"{module_path}.apps.{config_name}" + @staticmethod def is_django_project(directory: str = None) -> bool: if directory is None: