|
|
@ -4,7 +4,7 @@ from unfold.admin import ModelAdmin |
|
|
from unfold.decorators import display |
|
|
from unfold.decorators import display |
|
|
from django.utils.html import format_html |
|
|
from django.utils.html import format_html |
|
|
from django import forms |
|
|
from django import forms |
|
|
|
|
|
|
|
|
|
|
|
from dj_language.models import Language |
|
|
|
|
|
|
|
|
from filer.models.thumbnailoptionmodels import ThumbnailOption |
|
|
from filer.models.thumbnailoptionmodels import ThumbnailOption |
|
|
# from filer.admin.thumbnailoptionmodels import ThumbnailOptionAdmin as OriginalThumbnailOptionAdmin |
|
|
# from filer.admin.thumbnailoptionmodels import ThumbnailOptionAdmin as OriginalThumbnailOptionAdmin |
|
|
@ -85,12 +85,10 @@ class CommentAdminForm(forms.ModelForm): |
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
def __init__(self, *args, **kwargs): |
|
|
super().__init__(*args, **kwargs) |
|
|
super().__init__(*args, **kwargs) |
|
|
# 3. Explicitly overwrite the choices for the language field |
|
|
|
|
|
self.fields['language'].choices = [ |
|
|
|
|
|
('', '---------'), # Keeps the empty option since your model allows null=True |
|
|
|
|
|
('en', 'English'), |
|
|
|
|
|
('ru', 'Russian'), |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 2. Filter the actual database objects instead of hardcoding strings |
|
|
|
|
|
if 'language' in self.fields: |
|
|
|
|
|
self.fields['language'].queryset = Language.objects.filter(code__in=['en', 'ru']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CommentAdmin(ModelAdmin): |
|
|
class CommentAdmin(ModelAdmin): |
|
|
|