Misago
  • Introduction
  • Setup
    • Create server on Digital Ocean
    • Point domain at your server
    • Setup Misago on your Server
    • Upgrading your Misago to latest version
  • Settings
    • Accessing settings
    • Static settings reference
    • Dynamic settings reference
  • Coding style
  • GDPR Compliance Guide
  • Social authentication
  • User rank styles
  • Category styles
  • User authentication
  • Writing new admin actions
  • Permissions framework
  • View decorators
  • Context processors
  • Frontend context
  • Audit trail
  • Forms
  • Cache
  • Sending mails
  • Markup
  • Posting process
  • Profile fields
  • Threads types
  • Extending pages
  • Validating registrations
  • Validators
  • Search filters
  • Template tags
  • Shortcuts
  • View errors
  • Locales
Powered by GitBook
On this page
  • Dynamic settings
  • Accessing dynamic settings in python code
  • Accessing dynamic settings in template
  • Lazy settings
  • Static settings
  • Accessing static settings in python code
  • Django Settings Reference

Settings

PreviousUpgrading your Misago to latest versionNextStatic settings reference

Last updated 4 years ago

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:

def my_view(request):
    # get forum name
    request.settings.forum_name

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:

from django.static.management.base import BaseCommand

from misago.cache.versions import get_cache_versions
from misago.conf.dynamicsettings import DynamicSettings


class Command(BaseCommand):
    def handle(self, *args, **options):
        cache_versions = get_cache_versions()
        settings = DynamicSettings(cache_versions)
        self.stdout.write("Forum name: %s" % settings.forum_name)

Accessing dynamic settings in template

Dynamic settings object is made available to the templates as settings variable:

<title>{{ settings.forum_name }}</title>

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:

def my_view(request):
    # test if lazy setting has value
    if request.settings.some_lazy_setting:
        # get actual value of the setting
        lazy_setting_value = request.settings.get_lazy_setting_value("some_lazy_setting")

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:

from misago.conf import settings

if settings.MISAGO_USE_STOP_FORUM_SPAM:
    print("Misago is configured to use stop forum spam!")

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 .

Dynamic settings reference
Static settings reference
Django documentation