Skip to content

Add native Jinja2 extension for DRF template rendering (#4084)#9999

Open
M97Chahboun wants to merge 3 commits into
encode:mainfrom
M97Chahboun:add-jinja2-support
Open

Add native Jinja2 extension for DRF template rendering (#4084)#9999
M97Chahboun wants to merge 3 commits into
encode:mainfrom
M97Chahboun:add-jinja2-support

Conversation

@M97Chahboun

Copy link
Copy Markdown

Closes #4084

Summary

This PR adds native Jinja2 support for DRF's template rendering tags (render_form and render_field).

Previously, these tags only worked with Django's default template engine. When a project was configured to use the Jinja2 backend, attempting to use these tags resulted in TemplateSyntaxError or missing tag exceptions.

To resolve this without introducing third-party dependencies (like django-jinja), this PR introduces a new native Jinja2 extension: rest_framework.jinja2.DRFExtension.

Developers can now seamlessly register this extension in their Jinja2 environment to expose the render_form and render_field globals, matching the behavior provided for Django templates.

@auvipy
auvipy self-requested a review July 21, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Jinja2 support in DRF

1 participant