diff --git a/src/djinit/creators/files.py b/src/djinit/creators/files.py index 382696e..dbeaa91 100644 --- a/src/djinit/creators/files.py +++ b/src/djinit/creators/files.py @@ -285,6 +285,14 @@ class FileCreator(BaseService): core_subfolders = ["utils", "mixins", "middleware"] self._create_subdirectories_with_init(core_dir, core_subfolders, "apps/core/") + # Inject base model + CommonUtils.create_file_from_template( + os.path.join(core_dir, "base.py"), + "components/base.py-tpl", + {}, + "Created apps/core/base.py", + ) + # Create api directory structure api_dir = os.path.join(self.project_root, "api") CommonUtils.create_directory_with_init(api_dir, "Created api/__init__.py") @@ -352,6 +360,14 @@ class FileCreator(BaseService): components = ["admin", "models", "serializers", "tests", "urls", "views"] self._create_subdirectories_with_init(apps_dir, components, "apps/") + # Inject base model + CommonUtils.create_file_from_template( + os.path.join(apps_dir, "models", "base.py"), + "components/base.py-tpl", + {}, + "Created apps/models/base.py", + ) + # Create 'api' directory with v1 api_dir = os.path.join(apps_dir, "api") CommonUtils.create_directory_with_init(api_dir, "Created apps/api/__init__.py") @@ -401,6 +417,14 @@ class FileCreator(BaseService): components = ["admin", "api", "models", "tests"] self._create_subdirectories_with_init(project_dir, components, f"{self.module_name}/") + # Inject base model + CommonUtils.create_file_from_template( + os.path.join(project_dir, "models", "base.py"), + "components/base.py-tpl", + {}, + f"Created {self.module_name}/models/base.py", + ) + # Create README files for guidance CommonUtils.create_file_from_template( os.path.join(project_dir, "api", "README.md"), @@ -510,3 +534,15 @@ class FileCreator(BaseService): CommonUtils.create_file_with_content( filepath, json.dumps(config, indent=4), "Created .djinit configuration file" ) + + def create_standard_shared(self) -> None: + """Create shared directory and inject base model for standard structure.""" + shared_dir = os.path.join(self.project_root, "shared") + CommonUtils.create_directory_with_init(shared_dir, "Created shared/__init__.py") + + CommonUtils.create_file_from_template( + os.path.join(shared_dir, "base.py"), + "components/base.py-tpl", + {}, + "Created shared/base.py", + ) diff --git a/src/djinit/creators/setup.py b/src/djinit/creators/setup.py index 085148d..0c970a4 100644 --- a/src/djinit/creators/setup.py +++ b/src/djinit/creators/setup.py @@ -68,6 +68,7 @@ class SetupCreator: else: steps.append(("Creating Django apps", self.project_creator.create_apps)) steps.append(("Creating project URLs", self.file_creator.create_project_urls)) + steps.append(("Creating shared module", self.file_creator.create_standard_shared)) steps.extend( [ diff --git a/src/djinit/utils/django.py b/src/djinit/utils/django.py index 66e5ea7..2402e22 100644 --- a/src/djinit/utils/django.py +++ b/src/djinit/utils/django.py @@ -71,7 +71,6 @@ class DjangoHelper: ("urls.py", "config/urls.py-tpl", urls_context), ("wsgi.py", "config/wsgi.py-tpl", {"project_name": project_name}), ("asgi.py", "config/asgi.py-tpl", {"project_name": project_name}), - ("base.py", "components/base.py-tpl", {}), ] CommonUtils.create_files_from_templates(project_config_dir, project_files, f"{project_name}/")