peopledoc / django-mail-factory

Django Mail Manager
Other
72 stars 17 forks source link

Cache preview data? #58

Open bhrutledge opened 9 years ago

bhrutledge commented 9 years ago

It looks like get_preview_data() is called for every entry in settings.LANGUAGES, but it doesn't depend on the language. If get_preview_data() is non-trivial (e.g., hits the database, builds complex objects), this could be unnecessarily time-consuming. Maybe the preview data could be cached in an instance variable?

Natim commented 9 years ago

The reason why we did that is because some implementation of models fields translation return the right translation of a field with regard to the current user language. So in case we change the language we need to refresh this cache anyways