When writing a method for one of my model classes, I find that I want
to access a function from another module. The reference documentation
(http://www.djangoproject.com/documentation/model_api/#model-methods)
is plenty clear on the fact that you can't just import a module at the
top of the model-definition file and then use it from within a method,
but what's the best workaround? I ended up passing it in as a default
argument:
from django.core import meta
import my_module
...
class Poll(meta.Model):
...
def my_method(self, my_module=my_module):
return my_module.foo(self.question)
but that's not beautiful of course. And I could put the import inside
my method, but that's not ideal either. Any thoughts? Is this a
restriction that will be lifted by the magic removal branch? (And I
don't mean to sound whiny but when's the magic removal work planned to
be merged to the trunk? I can't wait!)