django-shop
django-shop copied to clipboard
Separate OrderDetailSerializer for views & email notifications?
The documentation says:
Another method for adding images to HTML emails is to inline their payload. This means that images, instead of referring them by URI, are inlined as a base64-encoded string. Easy-thumbnails offers a template filter named data_uri to perform this operation. This of course blows up the overall size of an email and shall only be used for small an medium sized images.
Both the order views and the notification use OrderDetailSerializer
to serialise the data. It would be useful to have separate serialiser settings so that different media can be supplied to views and notifications. I would expect the default implementation to reuse the same serialiser, to be backward compatible.
To be compliant with the other templates, I think it would be a better approach to add a snippet template named myshop/products/email-product-media.html
. This snippet shall be rendered whenever the ordered items are listed in an email.
What do you think about such a feature?
So in models/notification.py
the call to OrderDetailSerializer
will have an extra render_label
set to email
?
Sounds perfect!
yes, that's the idea.
Unfortunately, it didn't make it into 0.11. Maybe the next version.
Just for you information. Newer email clients do not accept inlined images as a base64-encoded strings anymore. Instead django-SHOP 1.0 now uses the new feature introduced in django-post_office-3.2.0 to inline images as inline-attachments.
The template myshop/products/email-product-media.html
is now used to render emails.