feat: enhance project setup with .env.sample, improved .gitignore, and app structure support

This commit is contained in:
sankalp committed 2025-11-08 21:51:18 +05:45
1 parent 21823fcc61
commit e34faae3a7
4 files changed
+94 -149

No files matched your search

+20
View File
@@ -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=
+61 -145
View File
@@ -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 # Python
__pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
# C extensions
*.so *.so
__pycache__/
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/ *.egg-info/
.installed.cfg dist/
build/
.eggs/
*.egg *.egg
MANIFEST
# PyInstaller # Django
# 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:
*.log *.log
local_settings.py local_settings.py
db.sqlite3 db.sqlite3
db.sqlite3-journal db.sqlite3-journal
*.sqlite3
# Flask stuff: # Environment
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
.env .env
.venv .venv
env/ env/
@@ -133,45 +29,65 @@ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
# Spyder project settings # IDEs
.spyderproject .vscode/
.spyproject .idea/
*.swp
*.swo
*~
.project
.pydevproject
.settings/
.ropeproject/
# Rope project settings # OS
.ropeproject .DS_Store
*.DS_Store
Thumbs.db
desktop.ini
# mkdocs documentation # Django specific
/site media/
staticfiles/
staticfiles/
static_root/
/static/
# mypy # Testing
.mypy_cache/ .coverage
.dmypy.json htmlcov/
dmypy.json .pytest_cache/
.tox/
coverage.xml
*.cover
.hypothesis/
.cache
# Pyre type checker # Logs
.pyre/ logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# pytype static type analyzer # Node modules (if using frontend tools)
.pytype/ node_modules/
# Cython debug symbols # Secret keys
cython_debug/ secret.txt
secrets.json
# PyCharm # Jupyter Notebook
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can .ipynb_checkpoints
# 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/
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration # Backup files
poetry.toml *.bak
*.tmp
*~
# ruff # Database
.ruff_cache/ *.db
*.sql
# LSP config files # Cloud
pyrightconfig.json .cloud
djinit.egg-info/
djinit.egg-info/*
+12 -4
View File
@@ -51,8 +51,12 @@ class AppManager:
return is_django_project(self.current_dir) return is_django_project(self.current_dir)
def _app_exists(self) -> bool: def _app_exists(self) -> bool:
is_nested, nested_dir, apps_base_dir = self._detect_project_structure() # For predefined structure, check in apps/ directory
app_path = os.path.join(apps_base_dir, self.app_name) 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) return os.path.exists(app_path)
def _create_django_app(self) -> bool: def _create_django_app(self) -> bool:
@@ -92,8 +96,12 @@ class AppManager:
content = f.read() content = f.read()
# Get the app's module path (e.g., "apps.users" or just "users") # Get the app's module path (e.g., "apps.users" or just "users")
is_nested, nested_dir, apps_base_dir = self._detect_project_structure() # For predefined structure, use "apps" as nested_dir
app_module_path = calculate_app_module_path(self.app_name, is_nested, 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 # Check if app is already in USER_DEFINED_APPS
existing_apps = extract_existing_apps(content) existing_apps = extract_existing_apps(content)
+1
View File
@@ -44,6 +44,7 @@ dependencies = [
"rich>=14.2.0", "rich>=14.2.0",
"ruff>=0.14.2", "ruff>=0.14.2",
"jinja2>=3.1.0", "jinja2>=3.1.0",
"django>=4.2,<6.0",
] ]
[project.urls] [project.urls]