Opened 11 years ago

Closed 9 years ago

#19966 closed New feature (wontfix)

Allow for silent or conditional loading of custom template tags

Reported by: anonymous Owned by: nobody
Component: Template system Version: 1.5
Severity: Normal Keywords:
Cc: jaap.roes@… Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In an effort to create a modular project I have included all custom tags / filters related to an app in that app's templatetags folder as instructed.

Should I ever want to use those tags in any general project templates (such as base templates or just any plain template which doesn't belong to that specific app) I must ensure that app is installed in the project settings. While I understand the need for the app to be installed for the tag to work I still want my project to remain modular and not break should I run {% load some_custom_tag_lib %} while the app is "turned-off".

It would be nice if there was some way to load the tag and use it silently (meaning it won't break if the app isn't loaded) or a way to condition the loading and usage of the tag if that app being installed while skipping it if the app isn't installed.

Change History (5)

comment:1 by Jacob, 11 years ago

Triage Stage: UnreviewedSomeday/Maybe

This is a good idea in theory, but without a practical suggestion (API, patch, etc.) there isn't much we can do to move it forward. Moving to "someday"; if someone comes up with a concrete proposal we can look at this again.

comment:2 by Aymeric Augustin, 10 years ago

This would also help for the common requirement of loading {% static %} from staticfiles when it's available, from Django's default tags when it isn't.

comment:3 by Jaap Roes, 9 years ago

I've implemented this a couple of years ago as django-friendly-tag-loader, PyPI / BitBucket

Wouldn't mind if it was included in Django. Is my approach acceptable?

comment:4 by Jaap Roes, 9 years ago

Cc: jaap.roes@… added

comment:5 by Jaap Roes, 9 years ago

Resolution: wontfix
Status: newclosed

Closing this, as discussed on #django-dev. Although useful in some cases it does not merit inclusion in Django core. For those who need it there is django-friendly-tag-loader.

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