Accessing settings
Misago settings belong to one of two groups:

Dynamic settings

Those settings are stored in database and can be changed at the runtime using interface provided by admin control panel.

Accessing dynamic settings in python code

Dynamic settings can be accessed through the settings attribute on request:
1
def my_view(request):
2
# get forum name
3
request.settings.forum_name
Copied!
This method is available only during http request life-cycle. If you need to access dynamic settings outside of it (eg. in management command), you will have to instantiate misago.conf.dynamicsettings.DynamicSettings manually:
1
from django.static.management.base import BaseCommand
2
3
from misago.cache.versions import get_cache_versions
4
from misago.conf.dynamicsettings import DynamicSettings
5
6
7
class Command(BaseCommand):
8
def handle(self, *args, **options):
9
cache_versions = get_cache_versions()
10
settings = DynamicSettings(cache_versions)
11
self.stdout.write("Forum name: %s" % settings.forum_name)
Copied!

Accessing dynamic settings in template

Dynamic settings object is made available to the templates as settings variable:
1
<title>{{ settings.forum_name }}</title>
Copied!

Lazy settings

Not all dynamic settings settings are available at all times. Some settings (called lazy settings), are only available as True or None when accessed. To obtain their "real" value you need to call the get_lazy_setting_value method on settings object:
1
def my_view(request):
2
# test if lazy setting has value
3
if request.settings.some_lazy_setting:
4
# get actual value of the setting
5
lazy_setting_value = request.settings.get_lazy_setting_value("some_lazy_setting")
Copied!

Static settings

Those settings must be available when Misago starts and are not changeable at the runtime (e.g. from admin control panel), hence the name "static".
To define or change those settings, you need to edit your site's settings.py

Accessing static settings in python code

Static settings are available as attributes on settings object importable from misago.conf.settings:
1
from misago.conf import settings
2
3
if settings.MISAGO_USE_STOP_FORUM_SPAM:
4
print("Misago is configured to use stop forum spam!")
Copied!
misago.conf.settings first attempts to read setting value in your site's settings.py, and when its not defined here, uses default value defined inside Misago source code.
misago.conf.settings is fully compatible with django.conf.settings. If your code is not accessing MISAGO_* settings, you can use either of those approaches for accessing static configuration. misago.conf.settings is only recommended when you are using MISAGO_* settings in your code.

Django Settings Reference

Django defines plenty of configuration options that control behaviour of different features that Misago relies on.
Those are documented and available in Django documentation.
Last modified 1yr ago