So you’re setting up a Satchmo store, but you don’t like how the default store pages look. Possibly you just want to override the layout of the product detail page, how do you do that without having to edit the Satchmo files themselves?
Basic Skinning
If you refer to my project layout article, you’ll see that I strongly suggest you set up a project directory with a “templates” directory in it. If you do that, then the key step is to make that directory the first priority when looking for a template file.
DIRNAME = os.path.dirname(__file__)
SATCHMO_DIRNAME = '/opt/framework/satchmo'TEMPLATE_DIRS = (os.path.join(DIRNAME, "templates"),os.path.join(SATCHMO_DIRNAME, "templates"),)
How it works
The way this works is that when Django goes looking for a template file, it looks in the template directories in the order you’ve given in that setting. Let’s say for example that you have two files: “product/product.html” and “base.html.”
If you have a project set up like this:
storename/templates/ (empty) satchmo/templates/ base.html product/product.html
Django will look for product/product.html first at storename/templates/product. Since it isn’t there, it will look in satchmo/templates/product.html and find it. The product.html template extends base.html, so once again Django will look first in storename/templates, then successfully in satchmo/templates.
Overriding
Overriding the product template then becomes obvious. Just copy it to storename/templates/product and edit as you desire.
storename/templates/product/ product.htmlsatchmo/templates/ base.html base_product.html
Once you’ve done this, Django will look in storename/templates/product and find product.html. It also needs base.html, and it will find it in satchmo/templates.
This works the same in every case. If you wanted to override the base account profile page, then you’d make a directory “contact” and copy or modify the default Satchmo file “contact/view_profile.html.”