0
を持っていない私が持っている機能:templatetagsファイルでは、なぜ私がメッセージを得るのです:「モジュール」オブジェクトが属性「load_source」
def load_from_file(filepath, expected_class):
mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
py_mod = imp.load_source(mod_name, filepath)
をし、それがokです。
しかし、私は/私のビューに、この関数をコピー&ペーストするとき、私はエラーを取得:これが動作しないのはなぜ
import os, imp
def get_module(request, position):
[...]
imod = load_from_file(settings.PROJECT_ROOT + '/core/manager/modules/' + mod.type.fileview + '.py', 'ModuleManager')
[...]
def load_from_file(filepath, expected_class):
[...]
:
'module' object has no attribute 'load_source'
私の例ビューを?
funcを呼び出す前に両方のモジュールでimpを実行して、別のものが得られるかどうかを確認してください –
はい、私自身のモジュールimp – Nips