On Feb 1, 2022, at 11:01 AM, Mark Sapiro <mark@msapiro.net> wrote:
On 2/1/22 09:47, Duane Raymond wrote:
Hi, I'm looking to do some radical customisation of the Postorius (and Hyperkitty) templates over the next 6 ish months and was wondering if there is a 'best practice' way to do this that will survive updates to MM3. I've searched around and not found much and also tested copying venv/lib/python3.7/site-packages/postorius/templates/postorius/lists/summary.html to var/templates/lists/summary.html As suggested in some posts - but it didn't seem to pick up the customisation - only customisations in the venv path worked - and they get overwritten on update.
The var/templates directory has a specific structure and is only for custom list specific, domain specific and sitewide templates used for notifications from Mailman core. It has nothing to do with Postorius or HyperKitty templates.
Is there a 'best' way for this? I'd also like to eventually share them with the community and maybe add them to the repo if people want that....but for now I'll start with my own experiments. (and if there is documentation I have missed for this, let me know!)
I don't know about a
best
way, but the way I do this is to keep all local mods as patches to the base and apply those patches as part of the upgrade process.
The best way to do this would be utilize Django’s template loader. See here1 for the documentation on how you can do this. You want to put the path where you are putting the templates under DIRS
option of the TEMPLATES
section.
Do make sure that you are keeping the directory structure correct so that Django can discover them. Like, Hyperkitty’s base.html should be in /custom/path/hyperkitty/base.html
, where /custom/path
is what you’ve setup in DIRS setting above.
One important point to note here is that we can’t promise to not break your custom template in future, because the values passed in the template’s context is not a public or stable API. So, it is technically possible for us to remove/change the variables that are being passed. In practice, I can’t remember when was the last time I removed a variable, so this would work better than patching since you are doing “radical customisation”, which Mark isn’t.
-- thanks, Abhilash Raj (maxking)