Django backend and gettext wrapper problem
See original GitHub issueIf I send message with subject wrapped into ugettext_lazy, PostMark backend falls down with the following error:
...
File "/usr/local/lib/python2.7/site-packages/postmark/core.py", line 44, in default
return super(PMJSONEncoder, self).default(o)
File "/usr/local/lib/python2.7/site-packages/simplejson/encoder.py", line 252, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <django.utils.functional.__proxy__ object at 0x7f35c0e1fa10> is not JSON serializable
I’ve solved this bug locally with subject=str(subject)
.
I think the best solution may be wrap subject and message body into str
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
django-admin makemessages --no-obsolete doesn't seem to ...
I ran makemessages command; It wrote a .po file as expected; Then I deleted gettext() line from view and saved file, verified runserver ......
Read more >Translation | Django documentation
Since string extraction is done by the xgettext command, only syntaxes supported by gettext are supported by Django. In particular, Python f-strings are...
Read more >Chapter 19: Internationalization - The Django Book
In this example, ugettext_lazy() stores a lazy reference to the string – not the actual translation. The translation itself will be done when...
Read more >Django i18n: A beginner's guide - Lokalise Blog
The gettext module is available for you to use only through the backend in Python; therefore, it is not possible for you to...
Read more >Django internationalization (i18n) tutorial - Localizely
django -admin startproject django_i18n_example ... Gettext is used by Django under the hood for all commands around the PO files that we will ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I bumped into this.
Use-case: several views that send an e-mail, and have the “subject” of such a mail in a class-level attribute instead of inside a function.
Also, it’s clear that it was intended to be supported.
Solution would be I think to either remove the custom encoder and explicitly not support it, or to patch the encoder to fully support the latest version of Django, by checking
__text_cast
.Thanks @sjoerdjob! If or when we fix this i’ll be referencing your details here.