✅ Purpose

Defines the HTML/CSS structure of a landing and optional JS files.

🧩 Fields

  • name — unique name
  • CSS — optional CSS text (stored under field name CSS)
  • HTML — required HTML template (Jinja2)
  • java_script_files — Many‑to‑Many to JavaScriptFile
  • preview — optional image (.jpg/.jpeg/.png, max 5 MB, 2000×2000)
  • notes — optional
  • owner — FK to User
  • created_at, updated_at

🧠 Methods

  • render_html()

    • renders HTML using Jinja2
    • context includes css (from CSS field)
    • unknown variables are preserved (KeepUndefined)
  • copy(user=None)

    • creates a new Template with name [copy <timestamp>] <original name>
    • copies CSS, HTML, preview, notes
    • copies all JavaScriptFile relations
  • __str__() → returns name

🔗 Relations

  • Landing.template — each Landing uses one Template