appengine improperly configured database error when trying to send mail (using django_bootstrap)

心不动则不痛 提交于 2019-12-25 05:15:00

问题


I am using django_bootstrap.py there are similar errors but i could not find solution to it. I am using django helper(please do not suggest non-rel)

What i was trying to do was, inside a static html js website attaching a feature of sending mail, through a contact form. The form would take the data, and jQuery would validate and make a POST AJAX request to the url "/sendmail/" the views.py i have the following code:

def sendmail(request):
    logging.info("here1")
    msg = request.POST['comment'];    sub = request.POST['subject']
    name = request.POST['name'];    frm = request.POST['email']
    sender = name + " " + frm
    logging.info(sender)
    a = mail.send_mail(sender=sender,
              to="to@example.com",
              subject=sub,
              body=msg)
    logging.info(request)
    logging.info(a)
    return http.HttpResponse("1")

I get absolutely no error when i remove the line:

a = mail.send_mail(sender=sender,
                  to="to@example.com",
                  subject=sub,
                  body=msg)

However with that line being there, i get the following error:

<class 'django.core.exceptions.ImproperlyConfigured'>: You haven't set the DATABASE_ENGINE setting yet.

I look at my settings.py file and try making some changes: 1 adding two lines as done in django-nonrel settings.py

   DATABASES['native'] = DATABASES['default']
   DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}

This gave a 500 error on server and the page did not open.

2 I tried putting

   DATABASE_ENGINE = 'dummy'

This works locally but doesnot work on server(appspot).

3 I tried putting

DATABASE_ENGINE = 'appengine'

This too gives a 500 error.

Please let me know how to solve it.


回答1:


This looks messed up in all sorts of ways. Don't use bootstrap.py, it looks outdated as it's trying to load django 0.96. GAE now supports django 1.3.

Please don't use the django helper. It's not being maintained or supported by anyone. If you have problems with it, the solution is to upgrade to nonrel.

I recommend installing django-nonrel properly. Keep in mind django-nonrel is a full replacement of django. Most of it's the same, but some parts are modified to work with appengine backends. You cannot take pieces of django-nonrel and expect it to work with normal django, without a fair bit of hackery. The DATABASES lines in the settings file will only work with django-nonrel.

http://www.allbuttonspressed.com/projects/djangoappengine

Django helper doesn't have an email backend that uses appengine's email API. That's available in Django-nonrel's djangoappengine package.




回答2:


If you are not using a database in your application, you can set DATABASES = {} in your settings.py file. This will fix the problem "You haven't set the DATABASE_ENGINE setting yet".



来源:https://stackoverflow.com/questions/9648966/appengine-improperly-configured-database-error-when-trying-to-send-mail-using-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!