HTML Template overide

M
  • 22 Mar '20

Hello,

I've been experimenting with django for the past few months, and I happened to stumble upon spirit. I started to play around with it, but when I tried to change the header and footer text, nothing happened. I then looked in most of the CSS files to see if there was a text overide of some sort, but I couldn't find anything. Could you please tell me how to change the text of the header and footer?

Thanks, Morgan.

nitely
Esteban C Borsani
  • 1
  • 22 Mar '20

The header text can be changed in the admin section, your user must be an admin to access it, the URL suffix is /st/admin/config/. If you want to override the HTML, the files are: templates/spirit/_footer.html and templates/spirit/_header.html, you can override them the regular Django way.

M
  • 19 Jun

My templates are actually in the folder /my-env/lib/python3.10/site-packages/spirit/topic/templates/spirit/topic, and other similar folders. Suspect they are not installed correctly. What is the correct way to install them into /templates folder?

O
ojophilip
Ojo Philip Odeniyi
  • 19 Jun

@miha_romanov, that's the correct way to install it. Inherit the template in you settings and copy the spirit forum template folder into your root template folder. You can then manipulate the template as you wish.

You can inherit from your base.html, but if you do this make sure you link the CSS of spirit in the head of your base.html

M

@ojophilip, Thanks for the answer! If I understand you right, you suggest adding the tag {% extends "base.html" %} to main templates of Spirit. Think it should work. However, since the Spirit templates are located in virtual environment, there are some drawbacks. First, this code is not affected by git commands (push, pull), etc., so I will have to edit the templates manually on every server (local, testing, production). Second, all these changes will disappear if I for some reason reinstall virtual environment.

I'm thinking about moving all the code of Spirit (Python, HTML, CSS, static files. etc.) from virtual environment to the folder inside of my main website project.

Do you think this is possible, and should it work?

O
ojophilip
Ojo Philip Odeniyi
  • 20 Jun

@miha_romanov, you can override the env template by placing the template folder in your project root directory, thus any update will only affect that of the env and not the one in your root directory.

You can then extend your base.html after placing spirit template folder in that root directory.

Like a said before, make sure you link the spirit static files to your base.html too

nitely
Esteban C Borsani
  • 23 Jun

yeah, you can override the templates the django way. No need to copy the Spirit source code to your project. Some parts of the base template can be extended without overriding the whole thing. See https://spirit.readthedocs.io…