Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13470 closed (duplicate)

Debug TEMPLATE_LOADERS causes 'source' to be set to "<unknown source>" when TEMPLATE_DEBUG is True

Reported by: sdeibel@… Owned by: nobody
Component: Uncategorized Version: 1.2-beta
Severity: Keywords: settings template_debug template_loaders template node source
Cc: sdeibel@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Alex)

A work around is to set settings.py TEMPLATE_LOADERS to start with (or
contain only) the following:

    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',

However, it seems it would be good to properly set 'source' on nodes when
TEMPLATE_DEBUG is True. To fix this, change template/loader.py's
BaseLoader.load_template to read as follows so that an origin object
is properly created and sent into get_template_from_string when
TEMPLATE_DEBUG is True:

    def load_template(self, template_name, template_dirs=None):
        source, origin = self.load_template_source(template_name, template_dirs)
        origin_obj = make_origin(origin, self, template_name, template_dirs)
        template = get_template_from_string(source, origin=origin_obj, name=template_name)
        return template, origin

This is based on the 1.2beta-1 release.

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Please use preview.

comment:2 Changed 4 years ago by kmtracey

  • Resolution set to duplicate
  • Status changed from new to closed

This has already been reported and fixed in #12992.

comment:3 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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.