[google-appengine] TemplateDoesNotExist: css/datastore.css

67 views
Skip to first unread message

allyourcode

unread,
May 6, 2010, 8:00:24 PM5/6/10
to Google App Engine
Hi,

I'm having a problem developing my GAE application. It's been reported
as issue 464 on the GAE issue tracker, but it's not getting any
attention, due to difficulties with reproducing the issue; hence, I'm
turning to the GAE group to look for support.

Restarting the dev server temporarily gets rid of the problem, but it
keeps coming back. I'm worried this problem will come up in
production, but we haven't released our app yet, so I've never had a
chance to see how it works in production.

One symptom of the problem is if you go to http://localhost:8000/_ah/admin/interactive
and enter a correct program, and it hit "Run Program", the following
output is (sporadically) generated:

Traceback (most recent call last):
File "c:\Program Files\Google\google_appengine\google\appengine\ext
\webapp\__init__.py", line 507, in __call__
handler.get(*groups)
File "C:\Program Files\Google\google_appengine\google\appengine\ext
\admin\__init__.py", line 737, in get
self.generate('datastore.html', values)
File "C:\Program Files\Google\google_appengine\google\appengine\ext
\admin\__init__.py", line 131, in generate
self.response.out.write(template.render(path, values,
debug=_DEBUG))
File "c:\Program Files\Google\google_appengine\google\appengine\ext
\webapp\template.py", line 80, in render
t = load(template_path, debug)
File "c:\Program Files\Google\google_appengine\google\appengine\ext
\webapp\template.py", line 108, in load
template = django.template.loader.get_template(file_name)
File "<app_root>\django.zip\django\template\loader.py", line 81, in
get_template
File "<app_root>\django.zip\django\template\loader.py", line 89, in
get_template_from_string
File "<app_root>\django.zip\django\template\__init__.py", line 166,
in __init__
File "<app_root>\django.zip\django\template\__init__.py", line 187,
in compile_string
File "<app_root>\django.zip\django\template\__init__.py", line 283,
in parse
File "<app_root>\django.zip\django\template\loader_tags.py", line
169, in do_extends
File "<app_root>\django.zip\django\template\__init__.py", line 283,
in parse
File "<app_root>\django.zip\django\template\loader_tags.py", line
147, in do_block
File "<app_root>\django.zip\django\template\__init__.py", line 283,
in parse
File "<app_root>\django.zip\django\template\loader_tags.py", line
187, in do_include
File "<app_root>\django.zip\django\template\loader_tags.py", line
102, in __init__
File "<app_root>\django.zip\django\template\loader.py", line 80, in
get_template
File "<app_root>\django.zip\django\template\loader.py", line 73, in
find_template_source
TemplateDoesNotExist: css/datastore.css

When I restart the server, visit some pages in my app in another
window, and go back to the original window containing the script was
trying to run in the Interactive Console, I'm able to run it
successfully without modification (this is how I know the program is
correct).

Here are my versions:

GAE SDK 1.2.7
Django 1.0
GAE Django Helper r95
Python 2.5.4
Windows XP Home Edition SP3

I know there's a new version of the SDK, but when I tried upgrading,
my app stopped working, so I reinstalled version 1.2.7, which is
(otherwise) working fine for me.

I know other people have experienced this. Has anyone found a
solution?

Thanks,

allyourcode

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Nick Johnson (Google)

unread,
May 7, 2010, 5:08:21 AM5/7/10
to google-a...@googlegroups.com
Hi,

It's impossible to suggest what might be wrong without seeing the code in question. It looks like you're probably running into problems with relative or absolute paths, or your css file is marked as static in your app.yaml.

You should definitely upgrade your SDK - 1.3.3 is the latest version, and 1.2.7 is very much out of date.

-Nick Johnson
--
Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047

allyourcode

unread,
May 8, 2010, 8:27:36 AM5/8/10
to Google App Engine
I think the problem is that my TEMPLATE_DIRS gets cleared at some
point, even though my app doesn't do that, at least not directly. My
guess is that this is happening somewhere in the SDK or Django helper
to implement the admin pages, but I can't tell which piece is doing
the manipulation :/.

I'll try to upgrade my SDK, but again, when I tried this before, my
app ended up dead in the water (forget what issues I was running into
before).

On May 7, 2:08 am, "Nick Johnson (Google)" <nick.john...@google.com>
wrote:
> > google-appengi...@googlegroups.com<google-appengine%2Bunsu...@googlegroups.com>
> > .

Fredrik Bonander

unread,
May 10, 2010, 3:25:48 PM5/10/10
to google-a...@googlegroups.com
I have a similar problem. When I updated to django 1.1 I get TemplateSyntaxError: Template u'../index.html' cannot be extended, because it doesn't exist.

It seams that the problem lies in that the TEMPLATE_DIRS is not set wrong. But I don't know how set in as a relative path.

Anyone successfully used django 1.1 in GAE?

..fredrik


--
Fredrik Bonander

the infinite power of the creative mind - 




Roger Hu

unread,
May 17, 2010, 4:13:38 PM5/17/10
to Google App Engine
This import is causing massive headaches on App Engine deployments
with TemplateDoesNotExist sporadic messages. Assuming you have Django
1.1 setup correctly, the global_settings.py file will setup
TEMPLATE_LOADERS to load from both the project dir (/templates) as
well as any INSTALLED_APPS dir. But we noticed sporadic issues with
App Engine reporting the issue:

TemplateDoesNotExist: Tried [u'/base/data/home/apps/
myapp1234/1-2-2-8.341999523263263665/templates/volunteer-11.html']

The reason?

By default, Django has these two TEMPLATE_LOADERS defined in its
global settings (defined in conf/global_settings.py):

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)

The second line tells Django to try all the INSTALLED_APPS dirs
whenever attempting to render an HTML template. For instance, we do
not need to specify volunteer-11.html because it will try to look
inside ragendja/templates, accounts/templates, and civio/templates, in
the order defined by INSTALLED_APPS inside settings.py:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.admin',
'ragendja',
'accounts',
'civio'
)


If you accidentally import this line in your Python code,

from google.appengine.ext.webapp import template

The GAE reconfigures TEMPLATE_LOADERS inside
google.appengine.ext.webapp.template:

import django.conf
try:
django.conf.settings.configure(
DEBUG=False,
TEMPLATE_DEBUG=False,
TEMPLATE_LOADERS=(
'django.template.loaders.filesystem.load_template_source',
),
)

+#from google.appengine.ext.webapp import template

The result is TemplateDoesNotExist messages that may or may not occur.

3. If you are using Django 1.1, you must be careful that you're not
importing google.appengine.ext.webapp import template. The solution,
I believe, is to simply remove all webapp dependency imports:

perl -pi.bak -e "s/^from google\.appengine\.ext\.webapp(.*)/#from
google.appengine.ext.webapp\1/g" *.py

We're still confirming that these changes will resolve the issue, but
it seems to explain the problem we have been having on Django 1.1.

Roger

On May 10, 12:25 pm, Fredrik Bonander
> >>> google-appengi...@googlegroups.com<google-appengine%2Bunsubscrib e...@googlegroups.com>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/google-appengine?hl=en.
>
> >> --
> >> Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. ::
> >> Registered in Dublin, Ireland, Registration Number: 368047
> >> Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
> >> 368047
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> >> To post to this group, send email to google-a...@googlegroups.com.
> >> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/google-appengine?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> > To post to this group, send email to google-a...@googlegroups.com.
> > To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/google-appengine?hl=en.
>
> --
> Fredrik Bonander
> carl.fredrik.bonan...@gmail.com
> +46 70 943 5441
>
> - the infinite power of the creative mind -
>
> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.

Fredrik Bonander

unread,
May 18, 2010, 9:05:26 AM5/18/10
to google-a...@googlegroups.com
Thanks. But I worked around the solution by adding a empty app to the INSTALLED_APPS that points to an empty .py file. Seems to work, but I get some random errors from my custom filers file saying that they don't exists.

When searching around I found that it's a bit confusing for many developers to get django 1.1 running. Is there any guides?

My main reason for upgrading to 1.1 is to use for-loop with {% for name, type in obj %}.

What is the mere basic you need to get 1.1 running (hopefully with out any random errors). As of now I only have a settings.py:

import os.path

PROJECT_DIR = os.path.dirname(__file__) # this is not Django setting.
TEMPLATE_DIRS = (
    os.path.join(PROJECT_DIR, "templates"),
    # here you can add another templates directory if you wish.
)


And in top of all my .py:

import os, sys, cgi, re, logging

# Google App Engine imports.
from google.appengine.ext.webapp import util

# Remove the standard version of Django.
for k in [k for k in sys.modules if k.startswith('django')]:
    del sys.modules[k]

# Force sys.path to have our own directory first, in case we want to import
# from it.
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))

# Must set this env var *before* importing any part of Django
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from google.appengine.dist import use_library
use_library('django', '1.1')
from django.conf import settings 
settings.configure(INSTALLED_APPS=('empty',)) 

from google.appengine.ext.webapp import template
....


What do I need to replace google's template import? Is there any other files I need? 

The solution above works (in some sense) but it seems a bit like it could break any moment. Especially pointing out a empty app and del modules from sys.modules.

Is there something google does to set the version to 0.96? And could these two settings interfere with each other?


..fredrik





--
Fredrik Bonander

the infinite power of the creative mind - 

allyourcode

unread,
Jun 18, 2010, 6:03:33 PM6/18/10
to Google App Engine
So, I finally tried installing version 1.3.4 of the SDK, which was a
bit of a headache, because my dev site would not start up after I did
this. I think this is due to https://code.google.com/p/google-app-engine-django/issues/detail?id=161
. To work around the issue, I added ipaddr supplied with the SDK to my
PYTHONPATH. I'm able to start my site now, but my original issue
(TemplateDoesNotExist) hasn't stopped happening. Another symptom of
the problem is different uncaught TemplateDoesNotExist exception with
the following message:

Your TEMPLATE_DIRS setting is empty. Change it to point to at least
one template directory.

This doesn't make sense, because my settings.py includes the
following:

TEMPLATE_DIRS = (
os.path.join(ROOT_PATH, 'templates')
)

This is why I believe TEMPLATE_DIRS is being cleared at some point,
something that I would never do in my app code. Another observation
that supports this theory is that the problem generally goes away when
I restart my server (I might have mentioned this before).

I'm going to try working around this by using the svn version of
google-app-engine-django (r105), but I haven't been able to use it it
for long, so I'm not sure if it'll make the problem go away.

grr...

On May 8, 5:27 am, allyourcode <allyourc...@gmail.com> wrote:
> I think the problem is that my TEMPLATE_DIRS gets cleared at some
> point, even though my app doesn't do that, at least not directly. My
> guess is that this is happening somewhere in the SDK or Django helper
> to implement the admin pages, but I can't tell which piece is doing
> the manipulation :/.
>
> I'll try to upgrade my SDK, but again, when I tried this before, my
> app ended up dead in the water (forget what issues I was running into
> before).
>
> On May 7, 2:08 am, "Nick Johnson (Google)" <nick.john...@google.com>
> wrote:
>
>
>
> > Hi,
>
> > It's impossible to suggest what might be wrong without seeing the code in
> > question. It looks like you're probably running into problems with relative
> > or absolute paths, or your css file is marked as static in your app.yaml.
>
> > You should definitely upgrade your SDK - 1.3.3 is the latest version, and
> > 1.2.7 is very much out of date.
>
> > -Nick Johnson
>

allyourcode

unread,
Jun 18, 2010, 8:51:59 PM6/18/10
to Google App Engine
After upgrading my sdk (to 1.3.4) and google-app-engine-django (to
r105), I'm still having problems with sporadic TemplateDoesNotExist
errors.

On Jun 18, 3:03 pm, allyourcode <allyourc...@gmail.com> wrote:
> So, I finally tried installing version 1.3.4 of the SDK, which was a
> bit of a headache, because my dev site would not start up after I did
> this. I think this is due tohttps://code.google.com/p/google-app-engine-django/issues/detail?id=161
> . To work around the issue, I added ipaddr supplied with the SDK to my
> PYTHONPATH. I'm able to start my site now, but my original issue
> (TemplateDoesNotExist) hasn't stopped happening. Another symptom of
> the problem is different uncaught TemplateDoesNotExist exception with
> the following message:
>
> Your TEMPLATE_DIRS setting is empty. Change it to point to at least
> one template directory.
>
> This doesn't make sense, because my settings.py includes the
> following:
>
> TEMPLATE_DIRS = (
>     os.path.join(ROOT_PATH, 'templates')
> )
>
> This is why I believe TEMPLATE_DIRS is being cleared at some point,
> something that I would never do in my app code. Another observation
> that supports this theory is that the problem generally goes away when
> I restart my server (I might have mentioned this before).
>
> I'm going to try working around this by using the svn version of
> google-app-engine-django (r105), but I haven't been able to use it it
> for long, so I'm not sure if it'll make the problem go away.
>
> grr...
>

allyourcode

unread,
Jun 23, 2010, 9:27:57 PM6/23/10
to Google App Engine
I'm using Django 1.0, so it may be that your advice doesn't apply to
me. In case it does, I tried following what you're saying.
Unfortunately, I'm find it quite difficult to understand what you
think the problem is. I get your point about how there's some config
in settings.py that sets what template loaders to use. I think what
you're saying is that some other file is clobbering that setting.
Specifically, you seem to be saying that if the following line exists
in one of my files, I'll get sporadic TemplateDoesNotExist errors:

from google.appeninge.ext.webapp import template

I did a grep on my project, and I don't have that line anywhere.
> To unsubscribe from this group, send email to ...
>
> read more »

chris

unread,
Jul 8, 2010, 4:32:17 PM7/8/10
to Google App Engine
I have been having this problem a lot. I was on Django 1.1 and now
also have it on 1.2.

I built a very simple reproduction case using the latest versions of
everything:

Mac OS X 10.5.8
Python 2.5.1
GAE 1.3.5
Django 1.2.1
google-app-engine-django r105

I submitted a new issue 3436 (http://code.google.com/p/googleappengine/
issues/detail?id=3436) that has all the code attached. Hopefully this
will help someone figure out what is going on.
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages