Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8682141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:41:27+00:00 2026-06-12T21:41:27+00:00

My problem started when the extends tag in a Django template could not reference

  • 0

My problem started when the extends tag in a Django template could not reference a base template in a parent dir. This question1 has a very good answer to the problem, but it disables the implicit template caching provided by the default template.render function in appengine.

The author of the answer also mentions that it would be fairly simple to implement this template caching, but I feel tampering with this kind of functionality will produce bugs in the future. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:41:29+00:00Added an answer on June 12, 2026 at 9:41 pm

    All of our template dirs are sub-folders of one template dir, so we just needed to get the loader to look there first.

    I haven’t tested if/how this breaks the template caching, but it doesn’t change the behaviour AFAICT.

    We did it by extending the base loader with a module alternative_path.py like this:

    class Loader(filesystem.Loader):
    """
    Looks for templates in an alternative path.
    
    Allows a template to extend a template which is located in a specified views path.
    """
    
    is_usable = True
    __view_paths = None
    
    def __init__(self, views_path):
        if Loader.__view_paths is None:
            Loader.__view_paths = [views_path]
    
    def get_alternative_template_sources(self, template_name):
        for template_dir in Loader.__view_paths:
            try:
                yield safe_join(template_dir, template_name)
            except UnicodeDecodeError:
                # The template dir name was a bytestring that wasn't valid UTF-8.
                raise
            except ValueError:
                # The joined path was located outside of this particular
                # template_dir (it might be inside another one, so this isn't
                # fatal).
                pass
    
    def get_template_sources(self, template_name, template_dirs):
        return itertools.chain(
            filesystem.Loader.get_template_sources(self, template_name, template_dirs),
            Loader.get_alternative_template_sources(self, template_name))
    

    Then in the same module:

    _loader = Loader

    Then in main.py:

    def main():
        views_path = os.path.join(os.path.dirname(__file__), 'templates')
        settings.TEMPLATE_LOADERS = (('web.rich.templates.alternative_path.Loader', views_path),
                                 'django.template.loaders.filesystem.Loader',
                                 'django.template.loaders.app_directories.Loader')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember running into this problem when I started using OpenGL in OS X.
I just started with facebook app development. Problem is that require statement is not
I'm trying to start a service after the device has been started. The problem
I'm having a major problem with this school assignment; lucky I started it early
I have a web app. I am using JSF2 framework. My problem started when
The problem I started with is that I want to display in an ASP.NET
I am having a problem that just started happening in OS 3.1. I have
Hi guys I'm a jquery noobie, just started jqueryUI Problem OverView: I'm trying to
So what started as A problem with buttons, just means there is A problem
I just started using Eclipse but already I have a small problem. At first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.