1

I'm currently keeping my templates in /projectdir/static/html/. I've begun to have enough of them that I've created a subdirectory: /projectdir/static/html/tag_request/. If I want to have a template in /tag_request/ inherit from one in /html/ how do I do it?

I've read that with django {% extends base.html %} should be written relative to /projectdir/templates/ or wherever TEMPLATE_DIRS points. How do I set TEMPLATE_DIRS in appengine (or do I have to put my templates in /projectdir/templates/)?

Thanks!

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
Hank
  • 3,603
  • 2
  • 17
  • 19
  • 3
    You shouldn't be storing program data (Eg, templates) in a static directory. If you've marked it as static in app.yaml, it won't be accessible from your code once it's uploaded. – Nick Johnson Apr 21 '11 at 02:27
  • Thanks. So the best solution would be to just to move my templates to '/projectdir/templates/' and adjust my code accordingly (since it shouldn't be in static anyway)? BTW What do you mean by "accessible from your code"? The app deploys OK. What am I loosing when I put templates in static? – Hank Apr 21 '11 at 16:32
  • I was just going in to implement the change mentioned in my last comment and I noticed that I never reference /html/ in my app.yaml. It only get's accessed through main.py. Is that why I don't have any issues so far? – Hank Apr 21 '11 at 16:37
  • It's only an issue if you list `/static` as a `static_dir` in app.yaml, which seemed likely given the name. Static files are served directly by the frontends without any involvement from your app, so they're not accessible by code. – Nick Johnson Apr 22 '11 at 01:03
  • Ahhh. My app.yaml only lists subdirectories of static (e.g. `static/css`, `static/js`). – Hank Apr 22 '11 at 03:07

1 Answers1

0

It seems to depend on which version of Django you are using.

If you're using 0.96, then just this works:

{% extends ../base.html %}

If you're using 1.2, then in theory you need to create a settings.py which sets the TEMPLATE_DIRS to /projectdir/static/html/, and then use this:

{% extends base.html %}

However I found a couple of issues with this - my solution is described here:

App engine default Django version change

Community
  • 1
  • 1
Saxon Druce
  • 17,406
  • 5
  • 50
  • 71