# django

URL: /kida/api/contrib/django/
Section: contrib
Description: Django integration for Kida.

Provides a Django template backend that uses Kida for rendering.

Setup in ``settings.py``::

    TEMPLATES = [
        {
            "BACKEND": "kida.contrib.django.KidaTemplates",
            "DIRS": [BASE_DIR / "templates"],
            "OPTIONS": {
                "autoescape": True,
                "extensions": [],
            },
        },
    ]

Then use Django's standard template rendering::

    from django.shortcuts import render

    def index(request):
        return render(request, "index.html", {"title": "Home"})

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/contrib/django/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fdjango%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fdjango%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fdjango%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fdjango%2Findex.txt)

Module

#
`contrib.django`

Django integration for Kida.

Provides a Django template backend that uses Kida for rendering.

Setup in`settings.py`::

```
TEMPLATES = [
    {
        "BACKEND": "kida.contrib.django.KidaTemplates",
        "DIRS": [BASE_DIR / "templates"],
        "OPTIONS": {
            "autoescape": True,
            "extensions": [],
        },
    },
]
```

Then use Django's standard template rendering::

```
from django.shortcuts import render

def index(request):
    return render(request, "index.html", {"title": "Home"})
```

2Classes

## Classes

`KidaTemplates`

3

▼

Django template backend for Kida.

Django template backend for Kida.

#### Methods

`from_string`

1

`KidaTemplate`

▼

Create a template from a string.

`def from_string(self, template_code: str) -> KidaTemplate`

##### Parameters

Name
Type
Description

`template_code`
`—`

##### Returns

`KidaTemplate`

`get_template`

1

`KidaTemplate`

▼

Load a template by name.

`def get_template(self, template_name: str) -> KidaTemplate`

##### Parameters

Name
Type
Description

`template_name`
`—`

##### Returns

`KidaTemplate`

Internal Methods
1

▼

`__init__`

1

▼

`def __init__(self, params: dict[str, Any]) -> None`

##### Parameters

Name
Type
Description

`params`
`—`

`KidaTemplate`

3

▼

Django-compatible template wrapper around a Kida Template.

Django-compatible template wrapper around a Kida Template.

#### Methods

`origin`

0

`Any`

▼

Template origin for Django's debug toolbar.

property

`def origin(self) -> Any`

##### Returns

`Any`

`render`

2

`str`

▼

Render the template with the given context.

`def render(self, context: dict[str, Any] | None = None, request: Any = None) -> str`

##### Parameters

Name
Type
Description

`context`
`—`

Template context dict.

Default:`None`

`request`
`—`

Django HttpRequest (added to context as 'request').

Default:`None`

##### Returns

`str`

Rendered HTML string.

Internal Methods
1

▼

`__init__`

1

▼

`def __init__(self, template: Any) -> None`

##### Parameters

Name
Type
Description

`template`
`—`
