diff --git a/{{ cookiecutter.name }}/.gitignore b/{{ cookiecutter.name }}/.gitignore index e3504745..b004738f 100644 --- a/{{ cookiecutter.name }}/.gitignore +++ b/{{ cookiecutter.name }}/.gitignore @@ -111,7 +111,7 @@ dmypy.json venv .venv -static .env db.sqlite +/static /media \ No newline at end of file diff --git a/{{ cookiecutter.name }}/Makefile b/{{ cookiecutter.name }}/Makefile index 410c94fc..f575f4a7 100644 --- a/{{ cookiecutter.name }}/Makefile +++ b/{{ cookiecutter.name }}/Makefile @@ -25,7 +25,6 @@ lint: uv run dotenv-linter src/app/.env.ci test: - @mkdir -p src/static uv run pytest --dead-fixtures uv run pytest --create-db --exitfirst --numprocesses ${SIMULTANEOUS_TEST_JOBS} diff --git a/{{ cookiecutter.name }}/src/app/conf/boilerplate.py b/{{ cookiecutter.name }}/src/app/conf/boilerplate.py index 93170a60..c4fed157 100644 --- a/{{ cookiecutter.name }}/src/app/conf/boilerplate.py +++ b/{{ cookiecutter.name }}/src/app/conf/boilerplate.py @@ -1,7 +1,10 @@ from pathlib import Path -BASE_DIR = Path(__file__).resolve().parent.parent +# Repository root directory +BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent + +SRC_DIR = BASE_DIR / "src" ROOT_URLCONF = "app.urls" diff --git a/{{ cookiecutter.name }}/src/app/conf/environ.py b/{{ cookiecutter.name }}/src/app/conf/environ.py index 5d98314f..21e22319 100644 --- a/{{ cookiecutter.name }}/src/app/conf/environ.py +++ b/{{ cookiecutter.name }}/src/app/conf/environ.py @@ -1,6 +1,6 @@ import environ # type: ignore[import-untyped] -from app.conf.boilerplate import BASE_DIR +from app.conf.boilerplate import SRC_DIR env = environ.Env( @@ -8,7 +8,7 @@ CI=(bool, False), ) -envpath = BASE_DIR / ".env" +envpath = SRC_DIR / "app" / ".env" if envpath.exists(): env.read_env(envpath) diff --git a/{{ cookiecutter.name }}/src/app/conf/i18n.py b/{{ cookiecutter.name }}/src/app/conf/i18n.py index 177f9612..040ac52f 100644 --- a/{{ cookiecutter.name }}/src/app/conf/i18n.py +++ b/{{ cookiecutter.name }}/src/app/conf/i18n.py @@ -1,10 +1,10 @@ -from pathlib import Path - -from app.conf.boilerplate import BASE_DIR +from app.conf.boilerplate import SRC_DIR LANGUAGE_CODE = "ru" -LOCALE_PATHS = [Path(BASE_DIR).parent / ".locale"] +LOCALE_PATHS = [ + SRC_DIR / ".locale", +] USE_i18N = True diff --git a/{{ cookiecutter.name }}/src/app/conf/media.py b/{{ cookiecutter.name }}/src/app/conf/media.py index 10a5aaa9..d6c605c1 100644 --- a/{{ cookiecutter.name }}/src/app/conf/media.py +++ b/{{ cookiecutter.name }}/src/app/conf/media.py @@ -1,5 +1,6 @@ +from app.conf.boilerplate import BASE_DIR from app.conf.environ import env MEDIA_URL = "/media/" -MEDIA_ROOT = env("MEDIA_ROOT", cast=str, default="media") +MEDIA_ROOT = env.path("MEDIA_ROOT", default=BASE_DIR / "media") diff --git a/{{ cookiecutter.name }}/src/app/conf/static.py b/{{ cookiecutter.name }}/src/app/conf/static.py index 14f494b5..dc7a7333 100644 --- a/{{ cookiecutter.name }}/src/app/conf/static.py +++ b/{{ cookiecutter.name }}/src/app/conf/static.py @@ -1,3 +1,4 @@ +from app.conf.boilerplate import BASE_DIR from app.conf.environ import env @@ -5,4 +6,4 @@ # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = "/static/" -STATIC_ROOT = env("STATIC_ROOT", cast=str, default="static") +STATIC_ROOT = env.path("STATIC_ROOT", default=BASE_DIR / "static") diff --git a/{{ cookiecutter.name }}/src/app/management/commands/startapp.py b/{{ cookiecutter.name }}/src/app/management/commands/startapp.py index c62f400e..171a55de 100644 --- a/{{ cookiecutter.name }}/src/app/management/commands/startapp.py +++ b/{{ cookiecutter.name }}/src/app/management/commands/startapp.py @@ -7,14 +7,14 @@ class Command(BaseCommand): def handle(self, **options): if "directory" not in options or options["directory"] is None: - directory = settings.BASE_DIR.parent / options["name"] + directory = settings.SRC_DIR / options["name"] directory.mkdir(exist_ok=True) options["directory"] = str(directory) if "template" not in options or options["template"] is None: - template = settings.BASE_DIR.parent / ".django-app-template" + template = settings.SRC_DIR / ".django-app-template" options["template"] = str(template)