Django¶
The Django adapter provides template tags and a function API that read their config from Django settings.
Prerequisites¶
- Python 3.10 or newer.
- Django 4.0 or newer.
Install¶
Configure¶
# settings.py
EASEO = {
"canonical_host": "example.com",
"public_base_url": "https://example.com",
"site_name": "Example",
"title_template": "{title} - Example",
}
If EASEO is missing, the adapter warns and falls back to localhost.
Options¶
Every SEOConfig field is supported in EASEO:
| Setting key | Type |
|---|---|
canonical_host |
str (required) |
public_base_url |
str (required) |
site_name |
str |
title_template |
str |
url_policy |
dict or URLPolicy |
default_robots |
dict or Robots |
search_robots |
dict or Robots |
default_og_image |
URL string, dict, or SEOImage |
publisher_name, publisher_logo |
str |
locale, locale_alternate, twitter_site |
str / list[str] |
auto_generate_schema, emit_warnings |
bool |
search_url_template |
str |
Template tags¶
Register the library and call the tags:
| Tag | Output |
|---|---|
{% easeo_head entity route %} |
Full <head> block |
{% easeo_title entity %} |
Just the <title> tag |
{% easeo_meta entity %} |
Just the meta description |
easeo_title and easeo_meta read the route from the request in the template
context.
Function API¶
Pass an explicit config as the third argument to bypass settings:
Patterns¶
Map a model to an entity¶
For schema-rich pages (products, articles), build an SEOEntity explicitly. See
the model mapping example.
ETag responses¶
Return the payload's deterministic ETag and answer 304 when it matches. See
the ETag example.
Troubleshooting¶
| Symptom | Cause |
|---|---|
No EASEO setting found warning |
EASEO is not defined in settings |
| Tags render nothing | easeo_tags was not loaded, or the entity lacks a title |
| Head appears escaped | The tag returns safe HTML; make sure your base template uses {{ ... }} not {{ ... | escape }} |
Notes¶
- Output is marked safe because the payload escapes its values.
- Entities need
entity_type,title, anddescription; a missingentity_typedefaults topage.