Deprecate "add_to_builtins" and replace with API on Template
|Reported by:||carljm||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
add_to_builtins modifies global process state. This is to be avoided whenever possible, and in this case there would be a much better alternative: provide an API on a Template object to inject templatetag libraries as "built-in" for that Template. This provides the same effect as add_to_builtins but in a localized and explicit way. If the tag library should be effectively built-in for the whole project, just use a custom render_to_response equivalent (or TemplateResponse subclass) that uses this API to inject the library for each Template rendered.
Deprecating add_to_builtins is another step on the path of cleaning up globally-stored settings-related state in Django, which needs to be done if we're going to clean up settings as process-global.
Change History (5)
comment:1 Changed 3 years ago by carljm
- Summary changed from Deprecate "add_to_builtins" to Deprecate "add_to_builtins" and replace with API on Template
comment:4 Changed 3 years ago by carljm
- Resolution set to duplicate
- Status changed from new to closed