Django Template tips
Today, we are going to cover a simple way to customise any template that lives in a third-party package, this includes django itself - most notably the admin & auth modules.
- Locate the which template contains the html you need to override and copy the contents and make a note of the path relative the parent
templates
directory. For example to the admin index template is located atdjango/contrib/admin/templates/admin/index.html
so we needadmin/index.html
- Recreate this file in your project with the exact same path under a templates directory.
- Paste in the exist contents of the template.
- Make your changes and see them reflected on the relevant page(s) in your browser
Done! Tomorrow another quick tip!