lundi 1 septembre 2014

Google App Engine - Django - Python - Ubuntu - Problems


Vote count:

0




I am reading 'Head First Python'. I am on Chapter 10 where Google App Engine is introduced. The initial hello world of using Python and Google App Engine was successful but subsequent programs have all failed.


I have the following app.yaml file:



application: three
version: 1
runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /.*
script: page368b.py

libraries:
- name: django
version: "1.3"


With the following Python code:



import wsgiref.handlers

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


from google.appengine.ext.db import djangoforms

import birthDB

class BirthDetailsForm(djangoforms.ModelForm):
class Meta:
model = birthDB.BirthDetails

class SimpleInput(webapp.RequestHandler):
def get(self):
html = template.render('templates/header.html', {'title': 'Provide your birth details'})
html = html + template.render('templates/form_start.html', {})
html = html + str(BirthDetailsForm(auto_id=False))
html = html + template.render('templates/form_end.html', {'sub_title': 'Submit Details'})
html = html + template.render('templates/footer.html', {'links': ''})
self.response.out.write(html)

def main():
app = webapp.WSGIApplication([('/.*', SimpleInput)], debug=True)
wsgiref.handlers.CGIHandler().run(app)

if __name__ == '__main__':
main()


There is a templates folder that the above Python module calls. They have HTML code in them with some Django code. Here is an example using the footer.html.



<p>
{{ links }}
</p>
</body>
</html>


The other HTML files are similar. I can start the Google App Engine with no problems using this command from BASH: python google_appengine/dev_appserver.py ~/Desktop/three The directory three contains the templates folder, the app.yaml file, the Python module shown above.


My problem is when I access the web-page at http://localhost:8080 nothing is there and the BASH shell where the command is run to start this shows all the calls in the Python program that caused the problem and then finally says: ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.


I have read in a few different places a few different things to try so I thought I would go ahead and make a new post and hope that some expert Python programmers would chime in and lend their assistance to a lost hobbit such as myself.


Regards,


user_loser



asked 43 secs ago







Google App Engine - Django - Python - Ubuntu - Problems

Aucun commentaire:

Enregistrer un commentaire