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.

  1. 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 at django/contrib/admin/templates/admin/index.html so we need admin/index.html
  2. Recreate this file in your project with the exact same path under a templates directory.
  3. Paste in the exist contents of the template.
  4. Make your changes and see them reflected on the relevant page(s) in your browser

Done! Tomorrow another quick tip!