django templates and inheritance

35 views
Skip to first unread message

lekonna

unread,
Apr 15, 2008, 5:02:02 AM4/15/08
to Google App Engine
I'm kinda new using django here but i can't figure out how to setup
basic Django template inheritance with
the app engine.

I tried the django {%block %} type of inheritance but run into:
<type 'exceptions.EnvironmentError'>: Settings already configured.
error when trying to configure the template dir. via:

from django.conf import settings
settings.configure(TEMPLATE_DIRS=("/gappeng/test/templates"))

Is there a way to make the Django template inheritance work with
appengine with small amount of work?

The basic single file template works just fine, but adding content via
the {% block %}results in no content being added ( with the templates
in the same dir as the base file) , this, i guess, due to the fact
that i don't know how to configure the dir where django would search
those templates from. Needless to say using only a single template
file is pretty messy and unefficient.

So how to accomplish this and how to get more debug info out of
django?

Michael Brunton-Spall

unread,
Apr 15, 2008, 6:11:05 AM4/15/08
to google-a...@googlegroups.com
I'm not entirely sure I understand quite what you mean, but template based inheritance works fine for my application. You should be view to view the code at http://code.google.com/p/shipwreck/source/browse
if you look in trunk/shipwreck/templates you can see that I have a tempalte called base.html which contains a number of {% block xxx %} directives, and in the index.html I have the first line being {% extends "base.html" %}

It could well be your configuration that is affecting it, you should amke sure that your django settings.py file has
ROOT_PATH = os.path.dirname(__file__)
and

TEMPLATE_DIRS = (
    ROOT_PATH + "/templates",
)

Hopefully that should fix it.

--
Michael Brunton-Spall
http://www.mibgames.co.uk

lekonna

unread,
Apr 15, 2008, 7:16:36 AM4/15/08
to Google App Engine
Thanks a bunch for the example Michael. Got it working now with your
help.

Actually works right out of the box without even modinfying the
settings.py. lovely, just the kind
of thing i've been looking for. I'd like to keep the application dir
as clean as possible with things that
only have to do with the content or creating the content of the
application, and keep the configuring
of the framework somewhere else.



Reply all
Reply to author
Forward
0 new messages