diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..03e6634 --- /dev/null +++ b/.env.sample @@ -0,0 +1,20 @@ +# Django settings +DJANGO_SETTINGS_MODULE=..settings.development +SECRET_KEY= your-secret-key +ALLOWED_HOSTS=api.your-domain.com,www.your-domain.com + +# Database (individual parameters) +DB_NAME= +DB_USER= +DB_PASSWORD= +DB_HOST= +DB_PORT= + +# Email settings +EMAIL_HOST= +EMAIL_PORT= +EMAIL_USE_TLS= +EMAIL_HOST_USER= +EMAIL_HOST_PASSWORD= +DEFAULT_FROM_EMAIL= +SERVER_EMAIL= diff --git a/.gitignore b/.gitignore index f1576c8..2b5243c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,130 +1,26 @@ #--------------------------------------------------# -# The following was generated with gitignore.nvim: # +# The following was generated by djinit: # #--------------------------------------------------# -# Gitignore for the following technologies: Python -# Byte-compiled / optimized / DLL files -__pycache__/ +# Python *.py[cod] *$py.class - -# C extensions *.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ +__pycache__/ *.egg-info/ -.installed.cfg +dist/ +build/ +.eggs/ *.egg -MANIFEST -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: +# Django *.log local_settings.py db.sqlite3 db.sqlite3-journal +*.sqlite3 -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments +# Environment .env .venv env/ @@ -133,45 +29,65 @@ ENV/ env.bak/ venv.bak/ -# Spyder project settings -.spyderproject -.spyproject +# IDEs +.vscode/ +.idea/ +*.swp +*.swo +*~ +.project +.pydevproject +.settings/ +.ropeproject/ -# Rope project settings -.ropeproject +# OS +.DS_Store +*.DS_Store +Thumbs.db +desktop.ini -# mkdocs documentation -/site +# Django specific +media/ +staticfiles/ +staticfiles/ +static_root/ +/static/ -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json +# Testing +.coverage +htmlcov/ +.pytest_cache/ +.tox/ +coverage.xml +*.cover +.hypothesis/ +.cache -# Pyre type checker -.pyre/ +# Logs +logs/ +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* -# pytype static type analyzer -.pytype/ +# Node modules (if using frontend tools) +node_modules/ -# Cython debug symbols -cython_debug/ +# Secret keys +secret.txt +secrets.json -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +# Jupyter Notebook +.ipynb_checkpoints -# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration -poetry.toml +# Backup files +*.bak +*.tmp +*~ -# ruff -.ruff_cache/ +# Database +*.db +*.sql -# LSP config files -pyrightconfig.json - -djinit.egg-info/ -djinit.egg-info/* +# Cloud +.cloud diff --git a/djinit/scripts/app_generator.py b/djinit/scripts/app_generator.py index 0b319df..9500aef 100644 --- a/djinit/scripts/app_generator.py +++ b/djinit/scripts/app_generator.py @@ -51,8 +51,12 @@ class AppManager: return is_django_project(self.current_dir) def _app_exists(self) -> bool: - is_nested, nested_dir, apps_base_dir = self._detect_project_structure() - app_path = os.path.join(apps_base_dir, self.app_name) + # For predefined structure, check in apps/ directory + if self._is_predefined_structure(): + app_path = os.path.join(self.current_dir, "apps", self.app_name) + else: + is_nested, nested_dir, apps_base_dir = self._detect_project_structure() + app_path = os.path.join(apps_base_dir, self.app_name) return os.path.exists(app_path) def _create_django_app(self) -> bool: @@ -92,8 +96,12 @@ class AppManager: content = f.read() # Get the app's module path (e.g., "apps.users" or just "users") - is_nested, nested_dir, apps_base_dir = self._detect_project_structure() - app_module_path = calculate_app_module_path(self.app_name, is_nested, nested_dir) + # For predefined structure, use "apps" as nested_dir + if self._is_predefined_structure(): + app_module_path = f"apps.{self.app_name}" + else: + is_nested, nested_dir, apps_base_dir = self._detect_project_structure() + app_module_path = calculate_app_module_path(self.app_name, is_nested, nested_dir) # Check if app is already in USER_DEFINED_APPS existing_apps = extract_existing_apps(content) diff --git a/pyproject.toml b/pyproject.toml index b053ef7..0c1fccc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ dependencies = [ "rich>=14.2.0", "ruff>=0.14.2", "jinja2>=3.1.0", + "django>=4.2,<6.0", ] [project.urls]