Code

Opened 3 years ago

Closed 3 years ago

#17368 closed Uncategorized (duplicate)

Document django.template.add_to_builtins() or provide a standard way to add template tags from view code

Reported by: anatoly techtonik <techtonik@…> Owned by: nobody
Component: Template system Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/dev/howto/custom-template-tags/

Currently, you need an obligatory {% load %} tag in all you templates if you want to use custom application tags. That's inconvenient. There is a django.template.add_to_builtins() function that accepts a string argument - a module name, which solves the problem. But this function is:

  1. Undocumented
  2. Module name is not convenient

I propose the following mechanism:

from codereview import customtags

django.template.add_library(customtags, default=True)

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #17085. Seem like it isn't worth pushing things in this path, but rather aim for the greater refactoring proposed in #17093.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.