On Mon, 7 Feb 2022 at 00:56, Abhilash Raj <maxking@asynchronous.in> wrote:
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 best way to do this would be utilize Django’s template loader. See here[1] 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 theTEMPLATES
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.
This looks promising! I've not got it working yet, but this is what I've tried:
- Created folder 'custom' in the mm root (in my case: /opt/mailman/mm/)
- Copied the files and folders from postorius/templates/postorius/* and hyperkitty/templates/hyperkitty/* to the custom/ folder (not the full postorius/templates/postorius/ match, just evening in the second postorius/ dirrectory)
- Recursive update of permissions of the custom/ folder and files to be mailman
- Updated /opt/mailman/mm/settings.py by changing "'DIRS': []" to "'DIRS': [BASE_DIR, '/custom/']" in the "TEMPLATES =" section
- Edited the original AND copied postorius/lists/summary.html to have a small change in the footer of each so I know what version it is serving
- Restarted: gunicorn qcluster mailman nginx and cleared browser cache
- Reloaded the 'info' page of a few lists to see which version ti was serving
Variants: I've also changed the DIRS value to the hard-coded path: /opt/mailman/mm/custom
Result: it is still serving the default/original Postorius template vs the custom one.
Any suggestions for things I should do to make it use the /custom/ folder instead? Any recompiling or other actions beyond just restarting? (I probably don't need to restart qcluster and maybe not even mailman core for this to take effect but I do it just in case!)
Cheers,
Duane