2015-05-15 11 views
8

यह मुझे पागल कर रहा है। मैंने कुछ अजीब किया है और ऐसा लगता है कि मेरी TEMPLATE_DIRS प्रविष्टियों को अनदेखा किया जा रहा है। मैं केवल एक settings.py फ़ाइल, परियोजना निर्देशिका में स्थित है, और इसे शामिल हैं:Django 1.8 TEMPLATE_DIRS को अनदेखा किया जा रहा है

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates'), 
    os.path.join(BASE_DIR, 'web_app/views/'), 
) 

मैं डाल रहा हूं/टेम्पलेट्स फ़ोल्डर में परियोजना स्तरीय टेम्पलेट्स, और उसके बाद में अलग दृष्टिकोण श्रेणियों के लिए फ़ोल्डर्स है मेरी ऐप फ़ोल्डर (जैसे प्रमाणीकरण विचार, खाता विचार, आदि)।

उदाहरण के लिए, अपने मुख्य सूचकांक पृष्ठ दृश्य web_app/विचारों/मुख्य/views_main.py में है और

from web_app.views.view_classes import AuthenticatedView, AppView 


class Index(AppView): 
    template_name = "main/templates/index.html" 

की तरह लग रहा है, जहां एक AppView सिर्फ TemplateView का एक विस्तार है। खाका-लोडर शवपरीक्षा जब मैं पृष्ठ पर जाने का प्रयास, मैं एक TemplateDoesNotExist अपवाद और बात यह है कि वास्तव में मुझे भ्रमित कर रहा है मिल गया है:: यहाँ मेरी समस्या है

Template-loader postmortem 

Django tried loading these templates, in this order: 
Using loader django.template.loaders.filesystem.Loader: 
Using loader django.template.loaders.app_directories.Loader: 
C:\Python34\lib\site-packages\django\contrib\admin\templates\main\templates\index.html (File does not exist) 
C:\Python34\lib\site-packages\django\contrib\auth\templates\main\templates\index.html (File does not exist) 

'टेम्पलेट्स' और 'web_app दुनिया में क्यों हैं/विचारों की निर्देशिका नहीं खोजी जा रही है? मैंने डीबगर के माध्यम से सेटिंग्स और views_main.py में ब्रेकपॉइंट की जांच की है और ऐसा लगता है कि वे वहां हैं। क्या किसी और को भी यही समस्या है? धन्यवाद।

उत्तर

24

आप Django का किस संस्करण का उपयोग कर रहे हैं? बजाय एक DjangoTemplates बैकएंड की DIRS विकल्प सेट करें: के बाद से 1,8

संस्करण 1.8 के बाद से पदावनत TEMPLATE_DIRS मान्य नहीं है।

https://docs.djangoproject.com/en/1.8/ref/settings/#template-dirs

बजाय इस कोशिश: https://docs.djangoproject.com/en/1.8/ref/templates/upgrading/

+0

हाँ:

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ # insert your TEMPLATE_DIRS here ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this # list if you haven't customized them: 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.contrib.messages.context_processors.messages', ], }, }, ] 

यहाँ एक उन्नत मार्गदर्शिका का लिंक है। वह यह था। वैसे यह दो घंटों का ठोस उपयोग था। धन्यवाद! – Gadzooks34

संबंधित मुद्दे