2012-08-10 1 views
15

は、私が得たエラーである:ここでは1.4.1で動作するようにdjangoの設定を行います。ここではローディングテンプレートエラー

ImproperlyConfigured: Error importing template source loader django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'" 

は私のローダテンプレートのコードです:

if DEBUG: 
    TEMPLATE_LOADERS = [ 
    'django.template.loaders.filesystem.Loader', 
    'django.template.loaders.app_directories.Loader',  
    ] 
else: 
    TEMPLATE_LOADERS = [ 
     ('django.template.loaders.cached.Loader',(
      'django.template.loaders.filesystem.load_template_source', 
      'django.template.loaders.app_directories.load_template_source', 
      'forum.modules.template_loader.module_templates_loader', 
      'forum.skins.load_template_source', 
      )), 
    ] 

このコードのすべての私は、インターネットからプロジェクトをダウンロードしたときがありました。 these instructionsを使用してOSQAを設定しようとしています。私はMS SQL Serverを実行しており、Python 2.6がインストールされています。このエラーを修正する方法についてのヘルプmanage.py runserverを実行し、私のものがセットアップされているhttpリンクをクリックしようとすると見つかりました)エラーがコマンドラインでポップアップします。私はDjangoPythonに新しくなっているので、何が起こっているのかを実際に診断する方法はわかりません。

+0

詳細については、2つのTEMPLATE_LOADERSを比較してください。実際の問題は古い* .filesystem.load_template_sourceと* .app_directories.load_template_source ...を使用しようとしていましたが、* .filesystem.Loaderにする必要があります。しかし、偉大な答え@ girasquid –

答えて

26

template loader types(キャッシュされたテンプレートローダーセクションまでスクロールダウン)のドキュメントを見ると、キャッシュされたローダーを設定したときに、まだそれをLoaderクラスに渡す必要があるように見えるので、設定を変更したいこのように見えるように:

if DEBUG: 
    TEMPLATE_LOADERS = [ 
    'django.template.loaders.filesystem.Loader', 
    'django.template.loaders.app_directories.Loader',  
    ] 
else: 
    TEMPLATE_LOADERS = [ 
     ('django.template.loaders.cached.Loader',(
      'django.template.loaders.filesystem.Loader', 
      'django.template.loaders.app_directories.Loader', 
      'forum.modules.template_loader.module_templates_loader', 
      'forum.skins.load_template_source', 
      )), 
    ] 

あなたがフィギュアにそのアプリのドキュメントを読んでする必要があります(私はローダーforumアプリのためにあるかわからないんだけど、あなたはおそらくも同様にそこLoaderクラスをしたいですキャッシュされたローダーで動作するサードパーティのテンプレートローダーではない)。

+0

私は別のエラーが出てきているので、私はそれを修正したと思う:)私はかなり確信しているこの1つよりも異なる... – dudebroman

+0

素晴らしい答え - ありがとう – nicorellius

+0

注 - 関数ベースのテンプレートローダーはDjango 1.4で削除されました:https://docs.djangoproject.com/en/1.10/internals/deprecation/#deprecation-removed-in-1-4。 –

4
  1. Twissandraプロジェクトの抽出された内容を含むフォルダ内の 'settings.py'ファイルを開きます。
  2. 検索、 'TEMPLATE_LOADERSは=(' とその中に、検索、 'django.template.loaders.filesystem.load_template_source'、この行をコメントと追加 'django.template.loaders.filesystem.Loader'。同様
  3. 、 '内TEMPLATE_LOADERS =('、検索、 'django.template.loaders.app_directories.load_template_source' とでそれを置き換える、 'django.template.loaders.app_directories.Loader'。

PS私は私の問題を解決しました。ありがとうHow to fix the Django error displayed when loading Twissandra for the first time?

関連する問題