Django Template & Static File Standards
Templates display data. Views handle requests. Models handle data. Business logic never lives in templates. CSS, JavaScript, and HTML are always separated — never mixed into one file.
Contents
| # | Section |
|---|---|
| 1 | The Three-Folder Rule |
| 2 | Static Folder Structure |
| 3 | Template Folder Structure |
| 4 | File Naming Standard |
| 5 | base.html Standard |
| 6 | Template Block Standards |
| 7 | CSS Organization Rules |
| 8 | JavaScript Rules |
| 9 | What Goes Where — Decision Table |
| 10 | Django App Template Isolation |
| 11 | Static File Loading |
| 12 | Reusable Template Components |
| 13 | Anti-Patterns to Avoid |
| 14 | Definition of Done — Django Template Work |
The Three-Folder Rule
static/
css/ <- All styles. Nothing else.
js/ <- All JavaScript. Nothing else.
images/ <- All images, icons, logos.
templates/ <- All HTML. No inline styles. No inline scripts.
Never:
- Write
<style>blocks inside an HTML template. - Write
<script>blocks with logic inside an HTML template. - Put images directly in your
templates/folder. - Mix styles from multiple components into one giant CSS file.
Reference Document
This page now follows the root source document. For the full section-by-section standard, use Django Template Standards.
