Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to display only those fields which are relevent to current language in admin panel? #776

Closed
kirmola opened this issue Feb 2, 2025 · 2 comments

Comments

@kirmola
Copy link

kirmola commented Feb 2, 2025

I have setted everything according to docs and I have nearly 40 i18n languages setted up, with 2 fields marked for translation, as per docs. Now if I open up admin panel to get details of a perticular object it will display, 40x2=80 fields which is disastrous to load, it took nealy 2 mins and caused around 4000 sql queries for me. 😢 .

here is how my setup looks like:
admin.py

from django.contrib import admin
from api.models import *
from modeltranslation.admin import TranslationAdmin
# Register your models here.


@admin.register(Application)
class ApplicationAdmin(admin.ModelAdmin):
    list_per_page = 50

for translation.py

from modeltranslation.translator import register, TranslationOptions
from api.models import Application, WhatsNew

@register(Application)
class AppDataTranslationOptions(TranslationOptions):
    fields = ('description', 'description_short',)


So the question is, is it possible to display translation fields only the currently activated langauge, for example here is a field description, and activated language being /de/, can we display only that field (description_de) in admin panel?

@kirmola kirmola changed the title Is it possible to get the fields relevent to current language in admin panel? Is it possible to display only those fields which are relevent to current language in admin panel? Feb 2, 2025
@kirmola
Copy link
Author

kirmola commented Feb 2, 2025

These are the issue here already created #526, #484, but they doesnt seems to suggest potential solution

@last-partizan
Copy link
Collaborator

No, it's not possible to display only current language.

django-modeltranslation use-case is mainly oriented at the usage where you want to translate a model into all your supported languages.

But, you can try looking at TranslationAdmin and writing your own implementation that displays only what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants