8

I am a noob trying to build an app on GAE. My app uses django templating features beyond those supported in version 0.96. I've not been able to get app engine (other than on the development server) to use the built in django 1.2 libraries.

I believe that this post might solve my problems except I don't know what appengine_config.py is. I assume I should include it in my project, but where and how? What should be in it other than the snippet in the post I referenced above?

Thanks!

Community
  • 1
  • 1
Hank
  • 3,603
  • 2
  • 17
  • 19

1 Answers1

5

appengine_config.py at the top level of your project is automatically imported by google.appengine.ext.webapp.util.run_wsgi_app() to add middlewear to webapp applications. The snippet you linked to should be sufficient to load django 1.2.

Simply paste it into appengine_config.py, and in your main.py (or wherever):

application = webapp.WSGIApplication([your_mappings])
run_wsgi_app(application)

Note that if you're not loading middlewear like appstats in appengine_config.py, you can actually just put the use_library() call directly into main.py; the key is to make sure it's always loaded before django is loaded from elsewhere on a given instance.

Wooble
  • 87,717
  • 12
  • 108
  • 131
  • Thanks for your reply. I'm not sure how to implement this. My best guess, which is probably not a very good one, is as follows: 1) Create a new file in my project directory called 'appengine_config.py' 2) use run_wsgi_app(appengine_config.py) to load it. (I've tried a couple variations along these lines and am doing further research, but a little more elaboration would be huge) Thanks again. – Hank Apr 05 '11 at 21:39
  • missed a step 1.5) paste snippet in appengine_config – Hank Apr 05 '11 at 21:45
  • clarified the use of run_wsgi_app() a bit; you don't need to tell it about your appengine_config.py, it's hardcoded in. – Wooble Apr 05 '11 at 21:56
  • Thank you very much! "the key is to make sure it's always loaded before django is loaded from elsewhere on a given instance" indeed! I hadn't thought about that. I had just tacked it onto the end of all of my imports. I just moved it to the top and now it works fine. Everything is handled at main, so that solves my problem. Thank you! I spent several hours on this. – Hank Apr 05 '11 at 22:13
  • p.s. I'm still not clear on where appengine_config.py is. If I did need to edit it, where do I find it? – Hank Apr 05 '11 at 22:16
  • 1
    @Hank: you just need to create it at the root of your application, in the same directory as app.yaml. – Wooble Apr 05 '11 at 23:14