1
votes

I am trying to get up to speed with wagtail. I am running it on a remote server. I have installed a virtual environment, then I switched to the virtual environment and installed wagtail as per the steps here: http://docs.wagtail.io/en/v1.9/getting_started/tutorial.html

  1. pip install wagtail
  2. wagtail start rocker
  3. cd rocker
  4. pip install -r requirements.txt
  5. python manage.py migrate
  6. python manage.py createsuperuser

The next step in the guide is to test the installation has worked by running:

python manage.py runserver

I can't do this as working with a remote server, and also there is already a Django app running on the server (using uwsgi).

So I am now trying to connect to this wagtail app, via uwsgi.

Using the string that starts the existing app as a template, I have modified it to bind a socket to the wagtail app: -

uwsgi --chdir=/opt/rocker/rocker --module=rocker.wsgi:application --env DJANGO_SETTINGS_MODULE=rocker.settings --master --pidfile=/tmp/rocker.pid --socket=/opt/rocker/core.sock --processes=5 --uid=www-data --gid=www-data --harakiri=20 --max-requests=5000 --vacuum --home=/opt/rocker --daemonize=/var/log/uwsgi/rocker.logroot@caspium:/etc/init.d#

However the app isn't starting... the error in the uwsgi log says the following: -

*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "./rocker/wsgi.py", line 18, in <module>
    application = get_wsgi_application()
  File "/opt/rocker/local/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/opt/rocker/local/lib/python2.7/site-packages/django/__init__.py", line 22, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/opt/rocker/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/opt/rocker/local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/opt/rocker/local/lib/python2.7/site-packages/django/conf/__init__.py", line 116, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
**django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.**
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 4617)
spawned uWSGI worker 1 (pid: 4622, cores: 1)
spawned uWSGI worker 2 (pid: 4623, cores: 1)
spawned uWSGI worker 3 (pid: 4624, cores: 1)
spawned uWSGI worker 4 (pid: 4625, cores: 1)
spawned uWSGI worker 5 (pid: 4626, cores: 1)

django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

I researched this and found this Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty which suggests adding

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings.local")

in manage.py which I did. This did not fix anything.

I also found this django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty which says you need a secret key specified in settings.py

However in the wagtail project there is no settings.py

I created one and added a secret key, and am still getting the error.

Can someone advise how I can fix this so I can run uwsgi to connect to the wagtail, and test if it's working.

Thanks

3

3 Answers

2
votes

In the Wagtail base project structure, settings.py is split into several files in the settings directory - see http://docs.wagtail.io/en/v1.9/reference/project_template.html#django-settings for details. The best place to put SECRET_KEY is settings/local.py, since you want to keep it out of version control.

0
votes

The problem was in the following file:

/opt/rocker/local/lib/python2.7/site-packages/django/conf/global_settings.py

There is a Secret Key = '' specified here.

I added a secret key, and the app ran ok with Uwsgi

0
votes

What worked for me after so many tries, was to delete the whole settings/ folder and create a proper settings.py file instead. If you guys from @Wagtail want to separate settings... you can do this https://simpleisbetterthancomplex.com/tips/2016/11/01/django-tip-19-protecting-sensitive-information.html