2014-10-03 85 views
0

我正在向webapp添加文本内容。 当我在本地服务器上运行的应用程序,我没有任何问题,但是当我上传模板到服务器返回我这个错误:django.template.loader找不到模板

Environment: 

Request Method: GET 
Request URL: http://www.centros-sbc.com/domiciliaciones 

Django Version: 1.5.1 
Python Version: 2.7.3 
Installed Applications: 
    ('django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.sites', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'django.contrib.humanize', 
    'suit', 
    'django.contrib.admin', 
    'sbcweb', 
    'south', 
    'compressor', 
    'django.contrib.sitemaps', 
    'captcha') 
Installed Middleware: 
    ('django.middleware.cache.UpdateCacheMiddleware', 
    'django.contrib.sessions.middleware.SessionMiddleware', 
    'django.middleware.locale.LocaleMiddleware', 
    'django.middleware.common.CommonMiddleware', 
    'django.contrib.messages.middleware.MessageMiddleware', 
    'django.middleware.cache.FetchFromCacheMiddleware') 

Template Loader Error: 
Django tried loading these templates, in this order: 
**Using loader django.template.loaders.filesystem.Loader: ** 
**/home/manager/webs/sbc-web/sbcweb/templates/general/domiciliaciones.html (File exists)** 

Using loader django.template.loaders.app_directories.Loader: 
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/general/domiciliaciones.html (File does not exist) 
/usr/local/lib/python2.7/dist-packages/suit/templates/general/domiciliaciones.html (File does not exist) 
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/general/domiciliaciones.html (File does not exist) 
**/home/manager/webs/sbc-web/sbcweb/templates/general/domiciliaciones.html (File exists)** 
/usr/local/lib/python2.7/dist-packages/compressor/templates/general/domiciliaciones.html (File does not exist) 
/usr/local/lib/python2.7/dist-packages/django/contrib/sitemaps/templates/general/domiciliaciones.html (File does not exist) 



Traceback: 
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 
115.       response = callback(request, *callback_args, **callback_kwargs) 
File "/home/manager/webs/sbc-web/sbcweb/views/general.py" in domiciliaciones 
27.  return render_to_response('general/domiciliaciones.html', response, context_instance=RequestContext(request)) 
File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py" in render_to_response 
29.  return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) 
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string 
170.   t = get_template(template_name) 
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in get_template 
146.  template, origin = find_template(template_name) 
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in find_template 
139.  raise TemplateDoesNotExist(name) 

Exception Type: TemplateDoesNotExist at /domiciliaciones 
Exception Value: general/domiciliaciones.html 

这里是我的模板装载机:

TEMPLATE_LOADERS = (
    #'django_mobile.loader.Loader', 
    'django.template.loaders.filesystem.Loader', 
    'django.template.loaders.app_directories.Loader', 
    #'django.template.loaders.eggs.Loader', 
) 

我的模板迪尔斯:

TEMPLATE_DIRS = (
    os.path.join(APP_PATH, "templates"), 
) 

应用程序路径:

APP_PATH = os.path.dirname(os.path.abspath(__file__)) 

这是事情。 我只是对/domiciliaciones.html的文本做了一些修改,处理了.po翻译文件并覆盖了翻译文件和.html我试图修复返回到原始页面(没有我的更改)的页面,但它也不工作。 如果有人可以帮助它会很好,我有点不顾一切地解决这个问题。 我不知道你是否需要有关该应用程序的更多信息,请让我知道!

非常感谢提前!

回答

1

也许我可以回答你的问题!在Django 1.8.2中,从版本1.8开始弃用:改为设置DjangoTemplates后端的DIRS选项。,所以,你不应该设置TEMPLATE_DIRS,在我opintion,你应该设置

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': ['templates'], 
     'APP_DIRS': True, 
     } 
] 

我花了一天半,我Web应用程序来解决这个问题!我想这会帮助你!

+0

谢谢。我正在使用Django 1.8.2,并且我有这个问题。像oyu一样搔了我几个小时。 – 2015-07-07 10:46:31