Skip to main content

EngineMixin

This class provides a standardized interface for accessing a template engine backend within a form-related context. It implements a cached property to initialize the engine with specific application directories and provides a convenience method for retrieving templates by name.

Attributes

AttributeTypeDescription
enginedjango.template.backends.base.BaseEngineThe template engine instance initialized with default settings for Django forms, including application directories and a specific backend path.

Methods


get_template()

@classmethod
def get_template(
template_name: string
) - > [Template](../../template/base/template.md?sid=django_template_base_template)

Retrieves a template object by its name using the configured template engine.

Parameters

NameTypeDescription
template_namestringThe name or path of the template file to be loaded by the engine

Returns

TypeDescription
[Template](../../template/base/template.md?sid=django_template_base_template)A template object that can be used for rendering content

engine()

@classmethod
def engine() - > [BaseEngine](../../template/backends/base/baseengine.md?sid=django_template_backends_base_baseengine)

Initializes and caches the template backend engine with default configurations for application directories and paths.

Returns

TypeDescription
[BaseEngine](../../template/backends/base/baseengine.md?sid=django_template_backends_base_baseengine)The initialized template backend instance configured for the djangoforms application