On 6/9/20 10:49 AM, Mark Dadgar wrote:
Here’s what I get when I attempt the above commands:
root@mail:/usr/lib/mailman3/bin# sudo -u list django-admin shell Python 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)
from hyperkitty.models import Email Traceback (most recent call last):
...
File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 60, in _setup raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
The django-admin
command that is being run doesn't itself point to
your settings. In my case, I run django-admin via a wrapper that contains
#!/bin/bash
. /opt/mailman/mm/venv/bin/activate
cd /opt/mailman/mm
export PYTHONPATH=/opt/mailman/mm
export DJANGO_SETTINGS_MODULE=settings
django-admin $@
The critical things are the exports of PYTHONPATH and DJANGO_SETTINGS_MODULE. The former is the path to where your settings module lives and the latter is its name without the .py extension.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan