Forums

Unhandled Exception: TemplateSyntaxError

On trying to launch my appDjango, I got an "Unhadled Exception" error. I checked my error logs and found this:

raise ImproperlyConfigured("You must specify a 'ENGINE' for database '%s'" % alias) django.template.base.TemplateSyntaxError: Caught ImproperlyConfigured while rendering: You must specify a 'ENGINE' for database 'default'.

How do I specify my default engine? I thought Simply entering my choice in my settings.py file handled that?

Thanks.

Hi altn8suniverse,

Yes it should. Do you want to post the database section of your settings.py (without the password/username of course) so we can take a look at it? You can send it through to us privately at support@pythonanywhere.com as well if you like.

Here it is:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'xxx$appname',                      # Or path to database file if using sqlite3.
        'USER': 'xxx',                      # Not used with sqlite3.
        'PASSWORD': 'password',                  # Not used with sqlite3.
        'HOST': 'mysql.server',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

Thank you.

EDIT: I see you've already noticed the formatting yourself and fixed it - good stuff! One hint is that since this is a Python file you can put :::python at the start of the block (indented by 4 characters as normal) to get syntax highlighting. I've deleted the part of my post which explained how to format blocks. (^_^)

I know very little about Django personally but it look mostly sensible to me. Not sure whether that NAME setting is correct - I assume the xxx means you've redacted it? Ah, but the exception above seems quite specific about not finding an engine, and it looks like you've definitely specified one. Mysterious.

Could it be that it's using a different settings.py file than that one, or that the permissions are such that it's not being read correctly? Still, you'd expect Django to give a more helpful error in the latter case... I think I'll leave this one to those with more Django experience than me! (i.e. some)

Hi altn8,

That looks completely fine to me, but I think you'll find that you are redefining DATABASES later in your settings.py. You could try commenting that later redefinition out. Just search for DATABASES and you'll be able to see where that happens.

@hansel: I am assuming you were talking about the "import dj_database_url" statement. I had actually hashed it out, as I couldn't remember why I included it in the first place. Running "python settings.py" gave no output. And I now have a new error "no module named app2.views.py". Checking the error logs shows that among other things, settings.py can not be found.

I set the path on my wsgi.py file as follows: :::pyhon path = '/home/user/myfolder' if path not in sys.path: sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'.

Thank you.

Okay, I can see a django error message at your URL now, so you are progressing!

From that error message I can see that you have set your path to /home/altn8suniverse/vizplat. Do you have a folder (or Python module) named ulogd2 inside /home/altn8suniverse/vizplat? Django doesn't seem to think so. That is what that error message is telling you.

Thanks. I think I'll just uninstall it (and hash out all references to it) since it isn't critical to my app. Thanks.