1

I have a working Django site that hosts locally without errors, however deploying it with Zappa gives me the following error:

The SECRET_KEY setting must not be empty.

Initially while getting setup with Django this error was caused by incorrectly pathed settings, but that was fixed and the SECRET_KEY is present in a base.py file.

One suggestion from the zappa output is to try turning "slim_handler" to false. Doing that results in the following error instead:

No module named django.core.wsgi

This is another error I had experienced before, when getting the site setup locally. It meant that Django was not present in the virtualenv I had setup (I checked, and the correct version is present now).

What might be the reason that a Django site would work fine when hosted locally, but would give errors (seemingly pathing related) when attempting to deploy with Zappa?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
hipsterstomper69
  • 317
  • 1
  • 6
  • 19
  • Probably theres a problem realated with a circular dependency in your django project. Take a look to this : https://stackoverflow.com/questions/19128540/django-improperlyconfigured-the-secret-key-setting-must-not-be-empty Are your aws keys and secret in place ? – mcrrnz Mar 27 '19 at 16:29
  • @marcocarranza Yes I saw that one too. It seems unlikely however, as the 'python manage.py runserver' script runs just fine locally. It's only when deploying with Zappa that I run into the error. – hipsterstomper69 Mar 27 '19 at 16:35
  • Are you using a virtualenv with your project? I had alot of issues with Zappa when the name of the proyect is the same as the name of the virtualenv. Renaming the env makes it work. – mcrrnz Mar 27 '19 at 16:38
  • @marcocarranza Yes I am using a venv with a unique name. I'm thinking that Zappa's lambda environment is either defaulting to some incorrect versions of dependencies, or perhaps its unable to find its dependencies entirely – hipsterstomper69 Mar 27 '19 at 16:39
  • Other thing you can test is to downgrade the Zappa version. I had some issues with version 0.48.x so i fall back to 0.47.1 – mcrrnz Mar 27 '19 at 16:47
  • I'm also noticing that during the 'downloading and installing dependencies' phase of the deployment, zappa gives me some warnings about how it is using 'precompiled lambda package versions' instead of the ones I specified. Possibly related? – hipsterstomper69 Mar 27 '19 at 16:49
  • Can you check if your python version is supported by Lambda? Also you need to change the slim handler setting to True, Django projects have a lot of dependencies – mcrrnz Mar 27 '19 at 18:07
  • Right, which gives me the wsgi error mentioned in the OP. Any thoughts on what that might be? – hipsterstomper69 Mar 27 '19 at 19:08

1 Answers1

0

The answer ended up being (probably) that I was using Django 1.9.x when Zappa requires 1.10+

hipsterstomper69
  • 317
  • 1
  • 6
  • 19