Skip to content

Commit

Permalink
Merge pull request #47 from saritasa-nest/feature/manage-file-configu…
Browse files Browse the repository at this point in the history
…ration

Add configuration option for manage.py file location
  • Loading branch information
yalef authored Nov 28, 2023
2 parents b85232c + 7a0ce36 commit 9a9e577
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ We follow [Semantic Versions](https://semver.org/).

## unreleased

- Add configuration for django `manage.py` file path
- Improve `pre-commit.run-hooks` command with `params`

## 0.9.1
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ be ready.

Requires [django_probes](https://github.com/painless-software/django-probes#basic-usage)

Settings:

* `manage_file_path` path to `manage.py` file (Default: `./manage.py`)

#### django.makemigrations

Run `makemigrations` command and chown created migrations (only for docker env).
Expand Down
1 change: 1 addition & 0 deletions saritasa_invocations/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class DjangoSettings:
default_superuser_password: str = "root"
shell_command: str = "shell_plus --ipython"
path_to_remote_config_file: str = "/workspace/app/config/settings/.env"
manage_file_path: str = "./manage.py"
settings_path: str = "config.settings.local"
app_boilerplate_link: str | None = None
app_template_directory: str = "."
Expand Down
8 changes: 6 additions & 2 deletions saritasa_invocations/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ def wait_for_database(context: invoke.Context) -> None:
https://github.com/painless-software/django-probes#basic-usage
"""
config = _config.Config.from_context(context)
if hasattr(wait_for_database, "_called"):
return
docker.up(context)
# Not using manage to avoid infinite loop
python.run(
context,
command="manage.py wait_for_database --stable 0",
command=(
f"{config.django.manage_file_path} " "wait_for_database --stable 0"
),
)
wait_for_database._called = True # type: ignore

Expand All @@ -45,11 +48,12 @@ def manage(
watchers: Automated responders to command
"""
config = _config.Config.from_context(context)
wait_for_database(context)
python.run(
context,
docker_params=docker_params,
command=f"manage.py {command}",
command=f"{config.django.manage_file_path} {command}",
watchers=watchers,
)

Expand Down

0 comments on commit 9a9e577

Please sign in to comment.