jazzband/django-constance

constance not initialized when setting up context processor

ericswpark opened this issue · 1 comments

I'm running into a problem where constance is not properly initialized before config/context_processor.py attempts to get one of the configuration values form constance, resulting in the following AttributeError:

AttributeError: module 'constance.settings' has no attribute 'CONFIGURATION_KEY'

When I use the management command to list keys I can verify that the config key is indeed there. So it seems like constance is not loaded/initialized before the context processor. How do I get values from constance in this case?

Sorry, never mind. I made a mistake when importing constance. I didn’t realize the object name was config, not settings.

Changing:

from constance import settings

to:

from constance import config

fixed the issue. I must’ve incorrectly assumed this object name because I was migrating from Django’s settings object and I thought the names would be the same. If anybody wants to migrate without changing the name then use the as import:

from constance import config as settings