I am trying to understand an other magic thing about django: it can convert strings to modules.
In settings.py, INSTALLED_APPS is declared like that:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
)
All it contains is strings. But django will convert those strings to modules and import them later.
I want to do be able to do the same thing. but i don't know how. I have a dictionary of renderer dispatcher in settings.py:
RESOUCE_RENDERER = {
'video': 'video_player',
'audio': 'audio_player',
}
I want to use it later like this: RESOURCE_RENDERER['video'](MyVideo)
.
I cannot assign directly the function name(eg video_player) because it lives in a module that needs settings.py.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With