-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
email template styling #268
Comments
Hi @woodz- , |
Hello @mrxsal, |
You can call your templates anything you like. Django doesn't require the html extension. A simple solution if you want to handle it all inside the template - try django compressor. You can output css inline. You could then run it through an email css optimizer |
Also (untested) you would probably write your snippet like this instead if you wanted to apply premailer that way:
|
I am a little bit of a django noobie but I thought at least I can explain how I got it working in the end. First of all, I am using bootstrap 5 for front-end styling. Initially I tried to style my emails just like how I would style my web pages, and I hoped that using django-premailer would enable me to do so.
As you can see, i'm utilizing the bootstrap styling, and it works like a charm. (tested on gmail) |
I may have a kind of confused understanding, when it comes to putting styles into email templates.
First I'd like to depict my rather ideal imagination.
From the message.html template I would derive a user defined one, putting / overriding head and body sections in there. While overriding the head section I'd introduce an external style sheet then taking over the super content. In the step of processing for sending an email, the premailer would transform the external style sheet into inline styles and finally the message is delivered to desired recipients, which are configured unter the Subscriptions admin section.
To be able to inherit from message.html, a modification of this template would be required, like this:
Then the derived template could look like this:
Following the doc of django-premailer, the derivation would look like:
At this point it comes to a dead end. Following the doc of premailer, we encounter a statement:
Since premailer only processes plain standard conform html, it fails to work on django templates due to lxml.
So my question is: what is a generic way of introducing styles in newsletter's templates, email templates especially?
@Sheepzez did this in the past by an any how configuration. Maybe it would be possible to shed some light on this? Here is the thread: #178, where I was also asking for details.
Thanks for taking time.
The text was updated successfully, but these errors were encountered: