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

Fields not translated when using QuerySet .values() method #47

Open
atodorov opened this issue Jul 2, 2021 · 1 comment
Open

Fields not translated when using QuerySet .values() method #47

atodorov opened this issue Jul 2, 2021 · 1 comment

Comments

@atodorov
Copy link
Collaborator

atodorov commented Jul 2, 2021

Inside Kiwi TCMS we're using the following pattern:

list(
    TestExecutionStatus.objects.filter(**query).values("id", "name", "weight", "icon", "color")
)

This returns the name field untranslated. From my limited experimentation I can tell that vinaigrette VinaigretteDescriptor doesn't seem to be triggered. (At least it doesn't reach the gettext part).

OTOH if I modify my code to look like:

result = []
for status in TestExecutionStatus.objects.filter(**query).distinct():
    result.append({
       "id": status.pk,
       "name": status.name,
       "weight": status.weight,
       "icon": status.icon,
       "color": status.color,
   })

then the values for name field are returned translated.

atodorov added a commit to kiwitcms/Kiwi that referenced this issue Jul 2, 2021
API methods TestExecutionStatus.filter() and TestCaseStatus.filter()
will now return translated values depending on the Accept-Language
header sent as part of the API request!

Related: ecometrica/django-vinaigrette#47
@atodorov
Copy link
Collaborator Author

@jordiecometrica, @rory-geoghegan-ecometrica ping. Can you provide some pointers here?

I can work on a PR to implement this but I don't want to rediscover the hot water before I can figure out if a solution is possible.

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

1 participant