I've implemented my own context processor and I'm trying to configure it properly in django's settings:
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as DEFAULT_PROCESSORS
MY_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'com.mysite.apps.myapp.processors.MyProcessor.MyProcessor.process',
)
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_PROCESSORS + MY_CONTEXT_PROCESSORS
but I got the following error:
Error importing request processor module com.mysite.apps.myapp.processors.MyProcessor.MyProcessor: "No module named MyProcessor"
MyProcessor
is a simple class with a static method "process
" (I love OOP and I use classes and package architecture in my project). It exits and is spelled correctly... so what's wrong?
UPDATE:
by replacing my class with a simple "process
" function ("com.mysite.apps.myapp.processors.MyProcessor.process
") it works... but I'm not satisfied... how does Django load these processors? I use a packages/classes approach everywhere in my app (models, tests, views...) and it usually works... what's the difference here? Since the dynamic nature of Python, a path like "com.mysite.apps.myapp.processors.MyProcessor.MyProcessor
" should be resolved independently from a class or a standard "submodule"... don't you agree?