Forums

Can't run any manage.py task (locally developed django app)

Hey there!

I'm having some real trouble trying to run an initial migration of my DB. I've set SECRET_KEY in <venv>/bin/postactivate and if i echo $SECRET_KEY it prints it out. However....When running manage.py migrate i get [The SECRET_KEY setting must not be empty].

(myv) 01:32 ~/annies360app (master)$ python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/core/management/__init__.py", line 195, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/core/management/__init__.py", line 39, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 16, in <module>
    from django.db.migrations.autodetector import MigrationAutodetector
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 13, in <module>
    from django.db.migrations.questioner import MigrationQuestioner
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/migrations/questioner.py", line 12, in <module>
    from .loader import MigrationLoader
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/migrations/loader.py", line 10, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 12, in <module>
    class MigrationRecorder(object):
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 26, in MigrationRecorder
    class Migration(models.Model):
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 27, in Migration
    app = models.CharField(max_length=255)
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 1072, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 166, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/conf/__init__.py", line 55, in __getattr__
    self._setup(name)
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/soulfulwater/.virtualenvs/myv/lib/python3.4/site-packages/django/conf/__init__.py", line 120, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

This is my first python app and first time deploying! Has anyone had a similar issue or could anyone point me in the right direction? I've searched the forums but I can't find a fix. My WSGI file seems to be configured correctly, as i can hit soulfulwater.pythonanywhere.com okay.

Thanks

Hi there,

the postactivate script doesn't get run for web apps. Check out this guide to setting env vars on pa for more info / tips on what to do.