How to delete empty archives by script?
Hi, We usually configure our lists to have no archives, but sometimes this is done after hyperkitty already creates the empty archive.
Is there a way (script) to delete empty archives using a script?
Regards, Andreas
On Mon, Oct 5, 2026 at 11:44 AM Andreas Vetter < andreas.vetter@uni-wuerzburg.de> wrote:
Hi, We usually configure our lists to have no archives, but sometimes this is done after hyperkitty already creates the empty archive.
Is there a way (script) to delete empty archives using a script?
- You can login to Postorius and delete the archive using that RED button.
- https://www.msapiro.net/scripts/prune_arch3
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 In an Internet failure case, the #1 suspect is a constant: DNS. "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-) [How to ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html]
On 10/5/26 4:43 AM, Andreas Vetter wrote:
Hi, We usually configure our lists to have no archives, but sometimes this is done after hyperkitty already creates the empty archive.
Is there a way (script) to delete empty archives using a script?
You could do the following in django-admin shell
>>> from hyperkitty.models import MailingList
>>> mlist = MailingList.objects.get(name='list@example.com')
>>> mlist.delete
replacing 'list@example.com' with the actual list.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Am Wednesday, 7 October 2026, 16:46:25 Central European Summer Time schrieb Mark Sapiro:
On 10/5/26 4:43 AM, Andreas Vetter wrote:
Hi, We usually configure our lists to have no archives, but sometimes this is done after hyperkitty already creates the empty archive.
Is there a way (script) to delete empty archives using a script?
You could do the following in
django-admin shell>>> from hyperkitty.models import MailingList >>> mlist = MailingList.objects.get(name='list@example.com') >>> mlist.deletereplacing 'list@example.com' with the actual list.
Cool. And since there are a lot of empty archives: How would I find the empty archives to feed to this? Can MailingList.objects.get() come up with something like a number of archived mails or threads or used space?
Thanks, Andreas
On 10/8/26 5:03 AM, Andreas Vetter wrote:
Cool. And since there are a lot of empty archives: How would I find the empty archives to feed to this? Can MailingList.objects.get() come up with something like a number of archived mails or threads or used space?
Something like
>>> from hyperkitty.models import MailingList
>>> for mlist in MailingList.objects.all():
... if len(mlist.emails.all()) == 0:
... print(mlist.name)
...
will print the names of all empty archived lists. either replace
print(mlist.name) with mlist.delete or add mlist.delete (indented
the same amount) after print(mlist.name) to delete them.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Am Thursday, 8 October 2026, 15:23:44 Central European Summer Time schrieb Mark Sapiro:
On 10/8/26 5:03 AM, Andreas Vetter wrote:
Cool. And since there are a lot of empty archives: How would I find the empty archives to feed to this? Can MailingList.objects.get() come up with something like a number of archived mails or threads or used space?
Something like
>>> from hyperkitty.models import MailingList >>> for mlist in MailingList.objects.all(): ... if len(mlist.emails.all()) == 0: ... print(mlist.name) ...will print the names of all empty archived lists. either replace
print(mlist.name)withmlist.deleteor addmlist.delete(indented the same amount) afterprint(mlist.name)to delete them.
First try, first problem:
from hyperkitty.models import MailingList Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/ __init__.py", line 25, in <module> from .category import ThreadCategory File "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/ category.py", line 64, in <module> class ThreadCategory(models.Model): File "/opt/mailman/venv/lib64/python3.11/site-packages/django/db/models/
(venv) mailman@lists:~> django-admin shell Python 3.11.15 (main, Aug 14 2026, 20:29:30) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) base.py", line 129, in __new__ app_config = apps.get_containing_app_config(module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/ registry.py", line 260, in get_containing_app_config self.check_apps_ready() File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/ registry.py", line 137, in check_apps_ready settings.INSTALLED_APPS File "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/ __init__.py", line 102, in __getattr__ self._setup(name) File "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/ __init__.py", line 82, 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.
I don't see INSTALLED_APPS in any of the configuration files. Where should this be defined?
TIA, Andreas
On Mon, Oct 12, 2026 at 12:13 PM Andreas Vetter < andreas.vetter@uni-wuerzburg.de> wrote:
Am Thursday, 8 October 2026, 15:23:44 Central European Summer Time schrieb Mark Sapiro:
On 10/8/26 5:03 AM, Andreas Vetter wrote:
Cool. And since there are a lot of empty archives: How would I find the empty archives to feed to this? Can MailingList.objects.get() come up with something like a number of archived mails or threads or used space?
Something like
>>> from hyperkitty.models import MailingList >>> for mlist in MailingList.objects.all(): ... if len(mlist.emails.all()) == 0: ... print(mlist.name) ...will print the names of all empty archived lists. either replace
print(mlist.name)withmlist.deleteor addmlist.delete(indented the same amount) afterprint(mlist.name)to delete them.First try, first problem:
from hyperkitty.models import MailingList Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/ __init__.py", line 25, in <module> from .category import ThreadCategory File "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/ category.py", line 64, in <module> class ThreadCategory(models.Model): File "/opt/mailman/venv/lib64/python3.11/site-packages/django/db/models/
(venv) mailman@lists:~> django-admin shell Python 3.11.15 (main, Aug 14 2026, 20:29:30) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) base.py", line 129, in __new__ app_config = apps.get_containing_app_config(module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/ registry.py", line 260, in get_containing_app_config self.check_apps_ready() File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/ registry.py", line 137, in check_apps_ready settings.INSTALLED_APPS File "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/ __init__.py", line 102, in __getattr__ self._setup(name) File "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/ __init__.py", line 82, 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.
I don't see INSTALLED_APPS in any of the configuration files. Where should this be defined?
What does your /etc/mailman3/settings.py look like?
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 In an Internet failure case, the #1 suspect is a constant: DNS. "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-) [How to ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html]
Am Monday, 12 October 2026, 11:20:27 Central European Summer Time schrieb Washington Odhiambo:
On Mon, Oct 12, 2026 at 12:13 PM Andreas Vetter <
andreas.vetter@uni-wuerzburg.de> wrote:
Am Thursday, 8 October 2026, 15:23:44 Central European Summer Time schrieb
Mark Sapiro:
On 10/8/26 5:03 AM, Andreas Vetter wrote:
Cool. And since there are a lot of empty archives: How would I find the empty archives to feed to this? Can MailingList.objects.get() come up with something like a number of archived mails or threads or used
space?
Something like
>>> from hyperkitty.models import MailingList >>> for mlist in MailingList.objects.all(): ... if len(mlist.emails.all()) == 0: ... print(mlist.name) ...will print the names of all empty archived lists. either replace
print(mlist.name)withmlist.deleteor addmlist.delete(indented the same amount) afterprint(mlist.name)to delete them.First try, first problem:
(venv) mailman@lists:~> django-admin shell Python 3.11.15 (main, Aug 14 2026, 20:29:30) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)
from hyperkitty.models import MailingList
Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/
__init__.py", line 25, in <module>
from .category import ThreadCategoryFile "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/
category.py", line 64, in <module>
class ThreadCategory(models.Model):File "/opt/mailman/venv/lib64/python3.11/site-packages/django/db/models/
base.py", line 129, in __new__
app_config = apps.get_containing_app_config(module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/
registry.py", line 260, in get_containing_app_config
self.check_apps_ready()File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/
registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPSFile "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/
__init__.py", line 102, in __getattr__
self._setup(name)File "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/
__init__.py", line 82, 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.
I don't see INSTALLED_APPS in any of the configuration files. Where should this be defined?
What does your /etc/mailman3/settings.py look like?
It is not in there (redacted for privacy):
(venv) mailman@lists:~> cat /etc/mailman3/settings.py # Mailman Web configuration file. # /etc/mailman3/settings.py
# Get the default settings. from mailman_web.settings.base import * from mailman_web.settings.mailman import *
# Settings below supplement or override the defaults.
#: Default list of admins who receive the emails from error logging. ADMINS = ( ('Mailman Suite Admin', 'redacted@redacted'), )
# Postgresql database setup. DATABASES = { 'default': { #'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mailmanweb', 'USER': 'mailman', # TODO: Replace this with the password. 'PASSWORD': 'redacted', 'HOST': 'localhost', 'PORT': '', # For MySQL/MariaDB, in addition to changing the 'ENGINE' setting, # uncomment the following to enable utf8 4-byte encodings. 'OPTIONS': {'charset': 'utf8mb4'}, } }
# 'collectstatic' command will copy all the static files here.
# Alias this location from your webserver to /static
STATIC_ROOT = '/opt/mailman/web/static'
HAYSTACK_CONNECTIONS['default']['PATH'] = '/opt/mailman/fulltext_index'
HYPERKITTY_ATTACHMENT_FOLDER = '/opt/mailman/hyperkitty' HYPERKITTY_ENABLE_GRAVATAR = False
# enable the 'compress' command. COMPRESS_ENABLED = True
# Make sure that this directory is created or Django will fail on start. LOGGING['handlers']['file']['filename'] = '/opt/mailman/web/logs/mailmanweb.log'
#: See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = [ "localhost", # Archiving API from Mailman, keep it. "127.0.0.1", "lists.redacted" # "lists.your-domain.org", # Add here all production domains you have. ]
#: See https://docs.djangoproject.com/en/dev/ref/settings/#csrf-trusted-origins #: For Django <4.0 these are of the form 'lists.example.com' or #: '.example.com' to include subdomains and for Django >=4.0 they include #: the scheme as in 'https://lists.example.com' or 'https://*.example.com'. CSRF_TRUSTED_ORIGINS = [ "https://lists.redacted" # "lists.your-domain.org", # Add here all production domains you have. ]
#: Current Django Site being served. This is used to customize the web host #: being used to serve the current website. For more details about Django #: site, see: https://docs.djangoproject.com/en/dev/ref/contrib/sites/ SITE_ID = 1
# Set this to a new secret value. SECRET_KEY = 'redacted'
# Set this to match the api_key setting in # /opt/mailman/mm/mailman-hyperkitty.cfg (quoted here, not there). MAILMAN_ARCHIVER_KEY = 'redacted'
# The sender of emails from Django such as address confirmation requests. # Set this to a valid email address. DEFAULT_FROM_EMAIL = 'redacted'
# The sender of error messages from Django. Set this to a valid email # address. SERVER_EMAIL = 'redacted'
############################## # Disable Sign-Up # AV following https://docs.mailman3.org/en/latest/faq.html#how-to-disable-signup ACCOUNT_ADAPTER = 'django_mailman3.views.user_adapter.DisableSignupAdapter' # # Disable Email verification, since we are using LDAP ACCOUNT_EMAIL_VERIFICATION = "none" # # At Login allow only username, not mailaddress del ACCOUNT_AUTHENTICATION_METHOD # Fehler: settings.ACCOUNT_AUTHENTICATION_METHOD is deprecated, use: settings.ACCOUNT_LOGIN_METHODS = {'username'} ACCOUNT_LOGIN_METHODS = {'username'} # Fehler: settings.ACCOUNT_EMAIL_REQUIRED is deprecated, use: settings.ACCOUNT_SIGNUP_FIELDS = ['email*', 'username*', 'password1*', 'password2*'] del ACCOUNT_EMAIL_REQUIRED
# LDAP setup # AV following https://gitlab.com/mailman/postorius/-/issues/132 AUTH_LDAP_SERVER_URI = "redacted" AUTH_LDAP_BIND_DN = "redacted" AUTH_LDAP_BIND_PASSWORD = "redacted" # If you use ldaps:// you must *not* set AUTH_LDAP_START_TLS. # AUTH_LDAP_START_TLS = True
import ldap from django_auth_ldap.config import LDAPSearch from django_auth_ldap.config import PosixGroupType
# This allow login using a username or an email address to login. AUTH_LDAP_USER_SEARCH = LDAPSearch("redacted", ldap.SCOPE_SUBTREE, "(&(objectClass=posixAccount)(uid=%(user)s))")
#AUTH_LDAP_GROUP_TYPE = PosixGroupType() #AUTH_LDAP_GROUP_SEARCH = LDAPSearch("redacted", # ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)")
AUTH_LDAP_USER_ATTR_MAP = { "username": "uid", "first_name": "givenName", "last_name": "sn", "email": "mail" }
#AUTH_LDAP_USER_FLAGS_BY_GROUP = { # "is_superuser": "cn=mailman- admins,ou=groups,dc=phl,dc=univie,dc=ac,dc=at" #}
AUTHENTICATION_BACKENDS = ( "django_auth_ldap.backend.LDAPBackend", "django.contrib.auth.backends.ModelBackend" )
Regards Andreas
On Mon, Oct 12, 2026 at 12:52 PM Andreas Vetter < andreas.vetter@uni-wuerzburg.de> wrote:
Am Monday, 12 October 2026, 11:20:27 Central European Summer Time schrieb Washington Odhiambo:
On Mon, Oct 12, 2026 at 12:13 PM Andreas Vetter <
andreas.vetter@uni-wuerzburg.de> wrote:
Am Thursday, 8 October 2026, 15:23:44 Central European Summer Time schrieb
Mark Sapiro:
On 10/8/26 5:03 AM, Andreas Vetter wrote:
Cool. And since there are a lot of empty archives: How would I find the empty archives to feed to this? Can MailingList.objects.get() come up with something like a number of archived mails or threads or used
space?
Something like
>>> from hyperkitty.models import MailingList >>> for mlist in MailingList.objects.all(): ... if len(mlist.emails.all()) == 0: ... print(mlist.name) ...will print the names of all empty archived lists. either replace
print(mlist.name)withmlist.deleteor addmlist.delete(indented the same amount) afterprint(mlist.name)to delete them.First try, first problem:
(venv) mailman@lists:~> django-admin shell Python 3.11.15 (main, Aug 14 2026, 20:29:30) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)
from hyperkitty.models import MailingList
Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/
__init__.py", line 25, in <module>
from .category import ThreadCategoryFile "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/
category.py", line 64, in <module>
class ThreadCategory(models.Model):File "/opt/mailman/venv/lib64/python3.11/site-packages/django/db/models/
base.py", line 129, in __new__
app_config = apps.get_containing_app_config(module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/
registry.py", line 260, in get_containing_app_config
self.check_apps_ready()File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/
registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPSFile "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/
__init__.py", line 102, in __getattr__
self._setup(name)File "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/
__init__.py", line 82, 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.
I don't see INSTALLED_APPS in any of the configuration files. Where should this be defined?
What does your /etc/mailman3/settings.py look like?
It is not in there (redacted for privacy):
(venv) mailman@lists:~> cat /etc/mailman3/settings.py # Mailman Web configuration file. # /etc/mailman3/settings.py
# Get the default settings. from mailman_web.settings.base import * from mailman_web.settings.mailman import *
# Settings below supplement or override the defaults.
#: Default list of admins who receive the emails from error logging. ADMINS = ( ('Mailman Suite Admin', 'redacted@redacted'), )
# Postgresql database setup. DATABASES = { 'default': { #'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mailmanweb', 'USER': 'mailman', # TODO: Replace this with the password. 'PASSWORD': 'redacted', 'HOST': 'localhost', 'PORT': '', # For MySQL/MariaDB, in addition to changing the 'ENGINE' setting, # uncomment the following to enable utf8 4-byte encodings. 'OPTIONS': {'charset': 'utf8mb4'}, } }
# 'collectstatic' command will copy all the static files here. # Alias this location from your webserver to
/staticSTATIC_ROOT = '/opt/mailman/web/static'HAYSTACK_CONNECTIONS['default']['PATH'] = '/opt/mailman/fulltext_index'
HYPERKITTY_ATTACHMENT_FOLDER = '/opt/mailman/hyperkitty' HYPERKITTY_ENABLE_GRAVATAR = False
# enable the 'compress' command. COMPRESS_ENABLED = True
# Make sure that this directory is created or Django will fail on start. LOGGING['handlers']['file']['filename'] = '/opt/mailman/web/logs/mailmanweb.log'
#: See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = [ "localhost", # Archiving API from Mailman, keep it. "127.0.0.1", "lists.redacted" # "lists.your-domain.org", # Add here all production domains you have. ]
#: See https://docs.djangoproject.com/en/dev/ref/settings/#csrf-trusted-origins #: For Django <4.0 these are of the form 'lists.example.com' or #: '.example.com' to include subdomains and for Django >=4.0 they include #: the scheme as in 'https://lists.example.com' or 'https://*.example.com '. CSRF_TRUSTED_ORIGINS = [ "https://lists.redacted" # "lists.your-domain.org", # Add here all production domains you have. ]
#: Current Django Site being served. This is used to customize the web host #: being used to serve the current website. For more details about Django #: site, see: https://docs.djangoproject.com/en/dev/ref/contrib/sites/ SITE_ID = 1
# Set this to a new secret value. SECRET_KEY = 'redacted'
# Set this to match the api_key setting in # /opt/mailman/mm/mailman-hyperkitty.cfg (quoted here, not there). MAILMAN_ARCHIVER_KEY = 'redacted'
# The sender of emails from Django such as address confirmation requests. # Set this to a valid email address. DEFAULT_FROM_EMAIL = 'redacted'
# The sender of error messages from Django. Set this to a valid email # address. SERVER_EMAIL = 'redacted'
############################## # Disable Sign-Up # AV following https://docs.mailman3.org/en/latest/faq.html#how-to-disable-signup ACCOUNT_ADAPTER = 'django_mailman3.views.user_adapter.DisableSignupAdapter' # # Disable Email verification, since we are using LDAP ACCOUNT_EMAIL_VERIFICATION = "none" # # At Login allow only username, not mailaddress del ACCOUNT_AUTHENTICATION_METHOD # Fehler: settings.ACCOUNT_AUTHENTICATION_METHOD is deprecated, use: settings.ACCOUNT_LOGIN_METHODS = {'username'} ACCOUNT_LOGIN_METHODS = {'username'} # Fehler: settings.ACCOUNT_EMAIL_REQUIRED is deprecated, use: settings.ACCOUNT_SIGNUP_FIELDS = ['email*', 'username*', 'password1*', 'password2*'] del ACCOUNT_EMAIL_REQUIRED
# LDAP setup # AV following https://gitlab.com/mailman/postorius/-/issues/132 AUTH_LDAP_SERVER_URI = "redacted" AUTH_LDAP_BIND_DN = "redacted" AUTH_LDAP_BIND_PASSWORD = "redacted" # If you use ldaps:// you must *not* set AUTH_LDAP_START_TLS. # AUTH_LDAP_START_TLS = True
import ldap from django_auth_ldap.config import LDAPSearch from django_auth_ldap.config import PosixGroupType
# This allow login using a username or an email address to login. AUTH_LDAP_USER_SEARCH = LDAPSearch("redacted", ldap.SCOPE_SUBTREE, "(&(objectClass=posixAccount)(uid=%(user)s))")
#AUTH_LDAP_GROUP_TYPE = PosixGroupType() #AUTH_LDAP_GROUP_SEARCH = LDAPSearch("redacted", # ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)")
AUTH_LDAP_USER_ATTR_MAP = { "username": "uid", "first_name": "givenName", "last_name": "sn", "email": "mail" }
#AUTH_LDAP_USER_FLAGS_BY_GROUP = { # "is_superuser": "cn=mailman- admins,ou=groups,dc=phl,dc=univie,dc=ac,dc=at" #}
AUTHENTICATION_BACKENDS = ( "django_auth_ldap.backend.LDAPBackend", "django.contrib.auth.backends.ModelBackend" )
While INSTALLED_APPS += ['XXXXXX'] would go into the settings.py, were you not supposed to be running 'mailman shell' instead of 'django-admin shell'?
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 In an Internet failure case, the #1 suspect is a constant: DNS. "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-) [How to ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html]
Am Monday, 12 October 2026, 12:08:40 Central European Summer Time schrieben Sie:
On Mon, Oct 12, 2026 at 12:52 PM Andreas Vetter <
andreas.vetter@uni-wuerzburg.de> wrote:
Am Monday, 12 October 2026, 11:20:27 Central European Summer Time schrieb
Washington Odhiambo:
On Mon, Oct 12, 2026 at 12:13 PM Andreas Vetter <
andreas.vetter@uni-wuerzburg.de> wrote:
Am Thursday, 8 October 2026, 15:23:44 Central European Summer Time
schrieb
Mark Sapiro:
On 10/8/26 5:03 AM, Andreas Vetter wrote:
Cool. And since there are a lot of empty archives: How would I find the empty archives to feed to this? Can MailingList.objects.get() come
up
with something like a number of archived mails or threads or used
space?
Something like
>>> from hyperkitty.models import MailingList >>> for mlist in MailingList.objects.all(): ... if len(mlist.emails.all()) == 0: ... print(mlist.name) ...will print the names of all empty archived lists. either replace
print(mlist.name)withmlist.deleteor addmlist.delete(indented
the same amount) after
print(mlist.name)to delete them.First try, first problem:
(venv) mailman@lists:~> django-admin shell Python 3.11.15 (main, Aug 14 2026, 20:29:30) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)
> from hyperkitty.models import MailingList
Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/
__init__.py", line 25, in <module>
from .category import ThreadCategoryFile "/opt/mailman/venv/lib64/python3.11/site-packages/hyperkitty/models/
category.py", line 64, in <module>
class ThreadCategory(models.Model):File
"/opt/mailman/venv/lib64/python3.11/site-packages/django/db/models/
base.py", line 129, in __new__
app_config = apps.get_containing_app_config(module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/
registry.py", line 260, in get_containing_app_config
self.check_apps_ready()File "/opt/mailman/venv/lib64/python3.11/site-packages/django/apps/
registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPSFile "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/
__init__.py", line 102, in __getattr__
self._setup(name)File "/opt/mailman/venv/lib64/python3.11/site-packages/django/conf/
__init__.py", line 82, 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.
I don't see INSTALLED_APPS in any of the configuration files. Where
should
this be defined?
What does your /etc/mailman3/settings.py look like?
It is not in there (redacted for privacy):
(venv) mailman@lists:~> cat /etc/mailman3/settings.py # Mailman Web configuration file. # /etc/mailman3/settings.py
# Get the default settings. from mailman_web.settings.base import * from mailman_web.settings.mailman import *
# Settings below supplement or override the defaults.
#: Default list of admins who receive the emails from error logging. ADMINS = (
('Mailman Suite Admin', 'redacted@redacted'),)
# Postgresql database setup. DATABASES = {
'default': { #'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mailmanweb', 'USER': 'mailman', # TODO: Replace this with the password. 'PASSWORD': 'redacted', 'HOST': 'localhost', 'PORT': '', # For MySQL/MariaDB, in addition to changing the 'ENGINE' setting, # uncomment the following to enable utf8 4-byte encodings. 'OPTIONS': {'charset': 'utf8mb4'}, }}
# 'collectstatic' command will copy all the static files here. # Alias this location from your webserver to
/staticSTATIC_ROOT = '/opt/mailman/web/static'HAYSTACK_CONNECTIONS['default']['PATH'] = '/opt/mailman/fulltext_index'
HYPERKITTY_ATTACHMENT_FOLDER = '/opt/mailman/hyperkitty' HYPERKITTY_ENABLE_GRAVATAR = False
# enable the 'compress' command. COMPRESS_ENABLED = True
# Make sure that this directory is created or Django will fail on start. LOGGING['handlers']['file']['filename'] = '/opt/mailman/web/logs/mailmanweb.log'
#: See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = [
"localhost", # Archiving API from Mailman, keep it. "127.0.0.1", "lists.redacted" # "lists.your-domain.org", # Add here all production domains you have.]
#: See https://docs.djangoproject.com/en/dev/ref/settings/#csrf-trusted-origins #: For Django <4.0 these are of the form 'lists.example.com' or #: '.example.com' to include subdomains and for Django >=4.0 they include #: the scheme as in 'https://lists.example.com' or 'https://*.example.com '. CSRF_TRUSTED_ORIGINS = [
"https://lists.redacted" # "lists.your-domain.org", # Add here all production domains you have.]
#: Current Django Site being served. This is used to customize the web host #: being used to serve the current website. For more details about Django #: site, see: https://docs.djangoproject.com/en/dev/ref/contrib/sites/ SITE_ID = 1
# Set this to a new secret value. SECRET_KEY = 'redacted'
# Set this to match the api_key setting in # /opt/mailman/mm/mailman-hyperkitty.cfg (quoted here, not there). MAILMAN_ARCHIVER_KEY = 'redacted'
# The sender of emails from Django such as address confirmation requests. # Set this to a valid email address. DEFAULT_FROM_EMAIL = 'redacted'
# The sender of error messages from Django. Set this to a valid email # address. SERVER_EMAIL = 'redacted'
############################## # Disable Sign-Up # AV following https://docs.mailman3.org/en/latest/faq.html#how-to-disable-signup ACCOUNT_ADAPTER = 'django_mailman3.views.user_adapter.DisableSignupAdapter' # # Disable Email verification, since we are using LDAP ACCOUNT_EMAIL_VERIFICATION = "none" # # At Login allow only username, not mailaddress del ACCOUNT_AUTHENTICATION_METHOD # Fehler: settings.ACCOUNT_AUTHENTICATION_METHOD is deprecated, use: settings.ACCOUNT_LOGIN_METHODS = {'username'} ACCOUNT_LOGIN_METHODS = {'username'} # Fehler: settings.ACCOUNT_EMAIL_REQUIRED is deprecated, use: settings.ACCOUNT_SIGNUP_FIELDS = ['email*', 'username*', 'password1*', 'password2*'] del ACCOUNT_EMAIL_REQUIRED
# LDAP setup # AV following https://gitlab.com/mailman/postorius/-/issues/132 AUTH_LDAP_SERVER_URI = "redacted" AUTH_LDAP_BIND_DN = "redacted" AUTH_LDAP_BIND_PASSWORD = "redacted" # If you use ldaps:// you must *not* set AUTH_LDAP_START_TLS. # AUTH_LDAP_START_TLS = True
import ldap from django_auth_ldap.config import LDAPSearch from django_auth_ldap.config import PosixGroupType
# This allow login using a username or an email address to login. AUTH_LDAP_USER_SEARCH = LDAPSearch("redacted",
ldap.SCOPE_SUBTREE, "(&(objectClass=posixAccount)(uid=%(user)s))")#AUTH_LDAP_GROUP_TYPE = PosixGroupType() #AUTH_LDAP_GROUP_SEARCH = LDAPSearch("redacted", # ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)")
AUTH_LDAP_USER_ATTR_MAP = {
"username": "uid", "first_name": "givenName", "last_name": "sn", "email": "mail"}
#AUTH_LDAP_USER_FLAGS_BY_GROUP = { # "is_superuser": "cn=mailman- admins,ou=groups,dc=phl,dc=univie,dc=ac,dc=at" #}
AUTHENTICATION_BACKENDS = (
"django_auth_ldap.backend.LDAPBackend", "django.contrib.auth.backends.ModelBackend")
While INSTALLED_APPS += ['XXXXXX'] would go into the settings.py, were you not supposed to be running 'mailman shell' instead of 'django-admin shell'?
From Marks Post:
You could do the following in django-admin shell
>>> from hyperkitty.models import MailingList
>>> mlist = MailingList.objects.get(name='list@example.com')
>>> mlist.delete
replacing 'list@example.com' with the actual list.
regards, Andreas
On 10/12/26 5:12 AM, Andreas Vetter wrote:
First try, first problem:
(venv) mailman@lists:~> django-admin shell Python 3.11.15 (main, Aug 14 2026, 20:29:30) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)
from hyperkitty.models import MailingList Traceback (most recent call last):
...
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.
I don't see INSTALLED_APPS in any of the configuration files. Where should this be defined? It is defined in mailman_web.settings.base which is imported by /etc/mailman3/settings.py. The issue is your django-admin command is not accessing the /etc/mailman3/settings.py file.
Did you ever try the interaction in <https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/ZA4EHLWBZITGZB275S435EBF4HRCC4EP/>? If so, what is the difference between the django-admin you ran there and this one?
In any case try
PYTHONPATH=/etc/mailman3 DJANGO_SETTINGS_MODULE=settings django-admin shell
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Works. My fault, see below:
On Monday, 12 October 2026 15:32:12 CEST Mark Sapiro wrote:
On 10/12/26 5:12 AM, Andreas Vetter wrote:
First try, first problem:
(venv) mailman@lists:~> django-admin shell Python 3.11.15 (main, Aug 14 2026, 20:29:30) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)
from hyperkitty.models import MailingList
Traceback (most recent call last): ...
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.
I don't see INSTALLED_APPS in any of the configuration files. Where should this be defined?
It is defined in mailman_web.settings.base which is imported by /etc/mailman3/settings.py. The issue is your django-admin command is not accessing the /etc/mailman3/settings.py file.
Did you ever try the interaction in <https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message /ZA4EHLWBZITGZB275S435EBF4HRCC4EP/>? If so, what is the difference between the django-admin you ran there and this one?
When I use mailman-web shell it works.
In any case try
PYTHONPATH=/etc/mailman3 DJANGO_SETTINGS_MODULE=settings django-admin shell
With this it works, too.
Both scripts work for me in "mailman-web shell".
I am sorry for the noise. The correct usage of django-admin is of course well documented here: https://docs.mailman3.org/en/latest/django-primer.html
Thank you for all the help, Andreas
participants (3)
-
Andreas Vetter -
Mark Sapiro -
Washington Odhiambo