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

  • SEARCH
  • Home
  • 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 3989088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:19:49+00:00 2026-05-20T06:19:49+00:00

Since app engine 1.4.2 was released, I am getting warnings like this in my

  • 0

Since app engine 1.4.2 was released, I am getting warnings like this in my production logs:

You are using the default Django
version (0.96). The default Django
version will change in an App Engine
release in the near future. Please
call use_library() to explicitly
select a Django version. For more
information see
http://code.google.com/appengine/docs/python/tools/libraries.html#Django

This occurs on every handler where I use a Django template – via the following:

from google.appengine.ext.webapp import template

I’d like to upgrade to 1.2, however the following links don’t seem very clear on exactly how to do this (or whether it works at all):

  • http://code.google.com/appengine/docs/python/tools/libraries.html#Django
  • http://code.google.com/p/googleappengine/issues/detail?id=1758
  • http://code.google.com/p/googleappengine/issues/detail?id=4489
  • http://www.mediacrafters.org/post/django11-on-appengine

The common thread is to insert this:

from google.appengine.dist import use_library
use_library('django', '1.2')

However, in what file(s) should this be inserted:

  1. Just in appengine_config.py?
  2. In every .py file which does from google.appengine.ext.webapp import template?
  3. In every .py file in the project?
  4. In 1 and (2 or 3) above, and also add import appengine_config to those files?
  5. In 3 or 4, and also add wrappers around built-in functions like appstats, remote api, datastore admin, etc?
  6. Something else?

Thanks.

  • 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-05-20T06:19:50+00:00Added an answer on May 20, 2026 at 6:19 am

    As described by Nick in the comments of systempuntoout’s answer, I inserted this use_library() code from here in every handler that imports django (either directly or via google.appengine.ext.webapp.template or even just django.utils.simplejson):

    from google.appengine.dist import use_library
    use_library('django', '1.2')
    

    As suggested by Nick, this was made easier by first refactoring to minimise the number of handlers referenced by app.yaml (ie, closer to scenario 1 described here).

    However, I have the appstats builtin configured, and if I first went to /_ah/appstats after an upload, then I would get this error:

    <‘google.appengine.dist._library.UnacceptableVersionError’>:
    django 1.2 was requested, but
    0.96.4.None is already in use

    I was able to fix this by also including the use_library() code in appengine_config.py.

    I noticed that by inserting a call to use_library() in appengine_config.py, then it was no longer necessary in all of my handlers. In particular the ones which import google.appengine.ext.webapp.template don’t need it, because importing webapp.template loads appengine_config.py. The appstats UI imports webapp.template, which is why this fixed that problem.

    However, I had some handlers (eg json services) which don’t import webapp.template, but do import django.utils.simplejson. These handlers still require a direct call to use_library(). Otherwise, if those handlers are called first on a new instance, the UnacceptableVersionError occurs. Although I am using appengine_config.py to configure appstats, meaning appengine_config.py gets called to instrument all requests, it gets called too late in the page lifecycle to properly configure the correct version of Django.

    This all appeared to work okay at first, but then I discovered a backwards incompatibility between the new Django 1.2 and the old Django 0.96 which I’d been using. My project structure is like this:

    root
    +- admin
    |  +- page_admin.html
    +- page_base.html
    

    With Django 0.96, having the following in page_admin.html worked fine:

    {% extends "../page_base.html" %}
    

    With Django 1.2, I got this error:

    TemplateDoesNotExist: ../page_base.html

    The change in Django 1.2 seems to be that by default, Django doesn’t allow loading templates which are above the original template’s directory.

    A workaround for this is described here, but this approach couldn’t work for me, as it requires the templates to be in a templates subdirectory.

    The solution to this is to set up a settings.py file, set the TEMPLATE_DIRS setting to the project root directory, and then change the extends tag to just reference "page_base.html", as described here. However, I ran into two problems trying to do this.

    I was using the recommended code to render my template, ie:

    template_values = { ... }
    path = os.path.join(os.path.dirname(__file__), 'page_admin.html')
    self.response.out.write(template.render(path, template_values))
    

    The first problem is that template.render() overrides the TEMPLATE_DIRS setting, to set it to the directory of the template being rendered. The solution to this is the following code:

    template_values = { ... }
    path = os.path.join(os.path.dirname(__file__), 'page_admin.html')
    template_file = open(path) 
    compiled_template = template.Template(template_file.read()) 
    template_file.close()  
    self.response.out.write(compiled_template.render(template.Context(template_values))) 
    

    One downside of this approach though is that template.render() caches the compiled templates, whereas this code doesn’t (although that wouldn’t be hard to add).

    To configure the TEMPLATE_DIRS setting, I added a settings.py to my project:

    PROJECT_ROOT = os.path.dirname(__file__) 
    TEMPLATE_DIRS = (PROJECT_ROOT,)
    

    And then in all of my handlers, before the use_library() code, I set the DJANGO_SETTINGS_MODULE as described here:

    import os
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 
    

    The second problem was that this didn’t work – the settings file wasn’t getting loaded, and so the TEMPLATE_DIRS was empty.

    Django settings are loaded from the specified settings.py lazily, the first time they are accessed. The problem is that importing webapp.template calls django.conf.settings.configure() to attempt to set up some settings. Therefore if webapp.template is imported before any settings are accessed, then settings.py is never loaded (as the settings accessor finds that settings already exist, and doesn’t attempt to load any more).

    The solution to this is to force an access to the settings, to load the settings.py, before webapp.template is imported. Then when webapp.template is later imported, its call to django.conf.settings.configure() is ignored. I therefore changed the Django version setup code in all of my handlers (and appengine_config.py) to the following:

    import os
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 
    
    from google.appengine.dist import use_library
    use_library('django', '1.2')
    
    from django.conf import settings
    _ = settings.TEMPLATE_DIRS
    

    In practise, I actually put all of the above code in a file called setup_django_version.py, and then import that from all of my handlers, rather than duplicating these 6 lines of code everywhere.

    I then updated my page_admin.html template to include this (ie specify page_base.html relative to the TEMPLATE_DIRS setting):

    {% extends "page_base.html" %}
    

    And that fixed the problem with rendering the admin page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since Google App Engine doesn't permit joins, does this mean that I have to
I'm using Google App Engine, Jquery and Django. I want POST data to be
Is BlazeDS 4 work with Google App Engine. I'm using BlazeDS 3.2.0 and getting
I'm using Django-nonrel on Google App Engine and have the following models (they are
Since the Google App Engine Datastore is based on Bigtable and we know that's
Since App Engine is so locked down I assume there is no way to
I've read this paragraph from the App Engine documentation a dozen times and still
The app engine datastore, of course, has downtime . However, I'd like to have
I'm building a site on Google App Engine, running python and Django non-rel. Everything
I am developing an App Engine App that uses memcache. Since there is only

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.