views:

1698

answers:

3

I am trying to include the following Tag In Google App Engine Web Application:

http://www.djangosnippets.org/snippets/1357/

Is there any configuration of this file to make it work with Google App Engine?

Cause I followed the Django Template tutorials: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/

and have this structure:

templatetags/
    __init__.py
    range_template.py

in the Template file, I have {%load range_template%}

But I am getting the error:

TemplateSyntaxError: 'range_template' is not a valid tag library: Could not load template library from django.templatetags.range_template, No module named range_template

The other thing that might be a problem why this ain't working is, the INSTALL_APPS settings.py file. Not sure how to configure it.

I have a settings.py file in the root of my application and included this:

INSTALLED_APPS = ('templatetags')

Any advice would be greatly appreciated.

+3  A: 

try doing the following:

$ python ./manage.py startapp foo

Add foo to installed apps:

INSTALLED_APPS += ('foo',)

And move your templatetags directory into your foo app. Something like:

./djangoproject
    __init__.py
    settings.py
    urls.py
    etc..
    foo/
        __init__.py
        templatetags/
            __init__.py
            range_template.py

Django convention is that template tag code resides in apps, in directories named templatetags (see docs). I assume the same would be true for GAE.

vezult
if I do this, do I need to also configure it on the google app engine production server?
TimLeung
I'm unsure of what you mean. Any changes that you want to effect your production server would have to be made to your production server, I imagine. I'm familiar with django, but not so much with Google's service environment.
vezult
When you do an appcfg.py update that will upload your local files into the AppEngine servers. So all the configuration you need to do is in your development environment, and it is mirrored on the servers by the appcfg.py update command.
dar
Per Siva's answer below - don't forget to restart the development server. This is one of the rare times where the change isn't picked up automatically.
KeithL
+3  A: 

In case someone searches for this, I wrote a small article in 2008 about this: http://daily.profeth.de/2008/04/using-custom-django-template-helpers.html

Joscha
+1  A: 

Please make sure to restart the development server after following the above step

Siva
This tripped me up when configuring smart_if for GAE. +1
KeithL