roverdotcom / django-inlinecss

A Django app useful for inlining CSS (primarily for e-mails)
Other
160 stars 94 forks source link

RichTextFields are not getting css #57

Open HenryMehta opened 2 years ago

HenryMehta commented 2 years ago

I have an email I'm sending which includes some django-ckeditor RichTextFields.

My file is of the form

{% load static css_inline thumbnail cms_tags scoring_tags inlinecss %}
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    ...
</head>
{% inlinecss 'dist/css/shortlist.css' %}
<body>
    <table align="center">
        <tbody>
            <tr>
                <td  class="shortlist">
                    <a href="some_url" class="shortlist"><img id="site-logo" src="path_to_image.png" alt="alt text" width="180px"></a>
                </td>
            </tr>
        </tbody>
    </table>
    <table width="591" border="0" align="center" cellpadding="6" cellspacing="3">
        <tbody>
            <tr>
                <td  class="shortlist" style="padding:10px 0px 0px 5px">
                    <span class="shortlist">
                            Dear {{ object.user.first_name }},
                    </span>
                </td>
            </tr>
            <tr>
                <td  class="shortlist" style="padding-bottom:15px;" >
                    <p class="shortlist">{{ object.auto_intro|safe }}</p>
                    {{ object.intro_email_text|safe }}
                </td>
            </tr>
    </table>
</body>
{% endinlinecss %}
</html>

object.intro_email_text is a RichTextField and no style information appears in the fields. object.auto_intro| is a simple text string

The css file is just this

body, p, td, span {
    font-size:12px;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.6;
    color: #000000
}

.shortlist {
    font-family: Arial, Helvetica, sans-serif;
    font-size:12px;
}

.btn-email {
    display: block;
    text-decoration: none;
    background-color: #FF7800;
    color: white;
    cursor: pointer;
    line-height: 50px;
    text-align: center;
    margin: 0px;
    height: 50px;
    padding: 0px 33px;
    border-radius: 5px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
}

Is there a way to get the style into the RichTextFields?