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

ugettext_lazy in Response with ujson #234

Open
chubz opened this issue Jul 28, 2016 · 0 comments
Open

ugettext_lazy in Response with ujson #234

chubz opened this issue Jul 28, 2016 · 0 comments

Comments

@chubz
Copy link

chubz commented Jul 28, 2016

Hi, I was wondering can the strings in responses in views get changed so rest-auth is compatible with UJSONRenderer?

Seems like ujson doesn't track well with Django's proxy objects when outputting json.
I've noticed that I get weird response from logout endpoint and managed to break it down to the message in the response.

return Response({"success": _("Successfully logged out.")},
                        status=status.HTTP_200_OK)

this results in such a response {"success":["S","u","c","c","e","s","s","f","u","l","l","y"," ","l","o","g","g","e","d"," ","o","u","t","."]}

I've noticed that if the string is evaluated by putting it in u'{}'.format(_("Successfully logged out.")) or through `unicode(_("Successfully logged out.")) the response is:
{"success": "Successfully logged out."}

Would ugettext_lazy removal be valid for this situation? If ugettext is used the message is as it should be!
If the goal is to support translation rather then optional renderers I'll fix it in my fork and keep it there but maybe using traslated strings a not lazily translated would be such a problem here?

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