feat(demo_data): use translation override to ensure consistent locale

wraps actions in a `with override("en")` block to enforce the use of the English locale during execution. This ensures consistent behavior and message formatting regardless of the server's default language settings.
This commit is contained in:
Egor Pavlovich Gorbunov 2026-02-27 19:02:55 +03:00
parent a59c5f59dd
commit 79be6ed4e4

View file

@ -10,6 +10,7 @@ from django.core.files.base import ContentFile
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.db import transaction from django.db import transaction
from django.utils import timezone from django.utils import timezone
from django.utils.translation import override
from engine.blog.models import Post, PostTag from engine.blog.models import Post, PostTag
from engine.core.models import ( from engine.core.models import (
@ -86,12 +87,13 @@ class Command(BaseCommand):
self._load_demo_data() self._load_demo_data()
if action == "install": with override("en"):
self._install(options) if action == "install":
elif action == "remove": self._install(options)
self._remove() elif action == "remove":
else: self._remove()
self.stdout.write(self.style.ERROR(f"Unknown action: {action}")) else:
self.stdout.write(self.style.ERROR(f"Unknown action: {action}"))
@property @property
def staff_user(self): def staff_user(self):