fix: "обход" скрытых миграций TagIt для продакшн.
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m34s

This commit is contained in:
2026-02-25 21:31:33 +03:00
parent c3c81d7ff5
commit 86bfd9b07b

View File

@@ -7,6 +7,7 @@ from django_select2.forms import Select2TagWidget
from taggit.models import Tag from taggit.models import Tag
from taggit.utils import parse_tags from taggit.utils import parse_tags
from django.db import models from django.db import models
from django.db.utils import OperationalError, ProgrammingError
try: try:
from etpgrf.typograph import Typographer from etpgrf.typograph import Typographer
@@ -34,8 +35,13 @@ class TagSelect2Widget(Select2TagWidget):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# choices: список всех существующих тегов по имени # choices: список всех существующих тегов по имени.
self.choices = [(t.name, t.name) for t in Tag.objects.all()] # Важно: на этапах вроде collectstatic таблицы taggit ещё может не быть,
# поэтому оборачиваем в try/except и молча игнорируем отсутствие БД.
try:
self.choices = [(t.name, t.name) for t in Tag.objects.all()]
except (OperationalError, ProgrammingError):
self.choices = []
class Media: class Media:
css = { css = {