Skip to content

Commit

Permalink
feat: simplified backend api project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav committed Dec 29, 2024
1 parent 4248080 commit edc1852
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"label": "Create superuser",
"type": "shell",
"command": "docker compose exec api uv run -- python src/manage.py createsuperuser",
"command": "docker compose exec api uv run -- python manage.py createsuperuser",
"isBackground": false
}
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ openssl rand -base64 32
There are two ways how to create new user account in the backend. First option is to run managed command responsible for creating superuser. It is more or less required, if you want to have an access to the Django admin. After running the command below, it will be possible to log in on the front end part of the application.

```bash
docker compose exec api uv run -- python src/manage.py createsuperuser
docker compose exec api uv run -- python manage.py createsuperuser
```

The second option how to create new user account is to register it on the front end. Turbo provides simple registration form. After account registration, it will be not possible to log in because account is inactive. Superuser needs to access Django admin and activate an account. This is a default behavior provided by Turbo, implementation of special way of account activation is currently out the scope of the project.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion backend/src/backend/asgi.py → backend/api/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "api.settings")

application = get_asgi_application()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions backend/src/backend/settings.py → backend/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

ALLOWED_HOSTS = ["localhost", "api"]

WSGI_APPLICATION = "backend.wsgi.application"
WSGI_APPLICATION = "api.wsgi.application"

ROOT_URLCONF = "backend.urls"
ROOT_URLCONF = "api.urls"

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

Expand All @@ -36,7 +36,7 @@
"rest_framework",
"rest_framework_simplejwt",
"drf_spectacular",
"backend",
"api",
]

######################################################################
Expand Down Expand Up @@ -91,7 +91,7 @@
######################################################################
# Authentication
######################################################################
AUTH_USER_MODEL = "backend.User"
AUTH_USER_MODEL = "api.User"

AUTH_PASSWORD_VALIDATORS = [
{
Expand Down Expand Up @@ -157,7 +157,7 @@
{
"title": _("Users"),
"icon": "person",
"link": reverse_lazy("admin:backend_user_changelist"),
"link": reverse_lazy("admin:api_user_changelist"),
},
{
"title": _("Groups"),
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion backend/src/backend/wsgi.py → backend/api/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "api.settings")

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion backend/src/manage.py → backend/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "api.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "backend"
name = "api"
requires-python = ">=3.13"
version = "0.1.0"
dependencies = [
Expand Down
38 changes: 19 additions & 19 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
timeout: 2s
retries: 10
api:
command: bash -c "uv sync && uv run -- python src/manage.py migrate && uv run -- python src/manage.py runserver 0.0.0.0:8000"
command: bash -c "uv sync && uv run -- python manage.py migrate && uv run -- python manage.py runserver 0.0.0.0:8000"
build:
context: backend
expose:
Expand Down

0 comments on commit edc1852

Please sign in to comment.