You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Django's TemplateView assigns the view object to the template context. Some applications and libraries rely on this fact to provide useful functionality (in my case, django-parler's get_translated_url template tag).
DRF's TemplateHTMLRenderer does not do this, and as far as I see, it does not provide a hook to pass extra context to the template from the view.
I propose to assign the view to the template context in TemplateHTMLRenderer.render(). This seems to be a trivial change: the view is already in the local scope via the renderer context.
In addition, do you think it would be a good idea to provide a way to pass extra context to the template when using TemplateHTMLRenderer?
The text was updated successfully, but these errors were encountered:
Considered this, nearly accepted, then argued myself out of it.
I'm not too keen on presenting view in the context, as I believe that more constrained behavior of pulling in exactly what is needed and no more is more manageable, maintainable, and that we should direct users down that path in their own interests.
Answer to both (1) & (2) is this: If you need different context (or different behavior) then I'd suggest overriding TemplateHTMLRenderer.
Appreciate you raising the ticket and talking this though - thanks!
Django's
TemplateView
assigns the view object to the template context. Some applications and libraries rely on this fact to provide useful functionality (in my case, django-parler'sget_translated_url
template tag).DRF's
TemplateHTMLRenderer
does not do this, and as far as I see, it does not provide a hook to pass extra context to the template from the view.TemplateHTMLRenderer.render()
. This seems to be a trivial change: the view is already in the local scope via the renderer context.TemplateHTMLRenderer
?The text was updated successfully, but these errors were encountered: