Opened 2 hours ago

#36731 new Bug

Allow TemplateView classes to have an asynchronous get_context_data method

Reported by: rrobles Owned by:
Component: Template system Version: 5.2
Severity: Normal Keywords: TemplateView, get_context_data, async
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, you can't use an asynchronous get_context_data in a TemplateView because it throws the following error:

TypeError: context must be a dict rather than a coroutine.

I've proposed some changes in this Pull Request:

https://github.com/django/django/pull/20081

These changes include a check to see if the context is a coroutine so it can be handled correctly in make_context. This allows you to handle get_context_data correctly when it's asynchronous.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top