worthwhile / django-herald

A Django messaging library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Buglets in notification browsing view

pakal opened this issue · comments

When viewing the HTML content of an Email class, the encoding is not properly set (utf8 in my case) so the text is garbled.

In text view, it's the content-type which seems abnormal, text/text should be text/plain, so the content gets downloaded as unknown instead of displayed as raw text.

Ah, I see what you mean about the text/text content type. I fixed that, and will submit a pull request request soon. But could you explain the encoding a little bit more? I have never run into that issue. Do you have an idea of how to fix it?

Ok found, when content_type has no charset in it, the browser displays it in the default charset of the browser (latin1 in my case). To solve his, you just need to add the charset to the content_type string.

From the docs of Django:
"content_type is the MIME type optionally completed by a character set encoding and is used to fill the HTTP Content-Type header. If not specified, it is formed by the DEFAULT_CONTENT_TYPE and DEFAULT_CHARSET settings, by default: “text/html; charset=utf-8”."

Here is the ending of testNotification->get() I used:

        render_type = "plain" if render_type == "text" else render_type
        return HttpResponse(content, content_type='text/{}; charset=utf-8'.format(render_type))

Fixed in #58.