在渲染时出现/捕获IOError的TemplateSyntaxError:(13,'权限被拒绝')

时间:2011-05-11 06:29:00

标签: python django apache mod-wsgi

这是页面上显示的错误

TracebackFile 
"/usr/local/lib64/python2.6/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args,      **callback_kwargs)
File "/usr/local/lib64/python2.6/site-packages/django/views/generic/simple.py" in direct_to_template
  28.     return HttpResponse(t.render(c), mimetype=mimetype)
File "/usr/local/lib64/python2.6/site-packages/django/template/base.py" in render
  123.             return self._render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/base.py" in _render
  117.         return self.nodelist.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/usr/local/lib64/python2.6/site-packages/django/template/debug.py" in render_node
  73.             result = node.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/loader_tags.py" in render
  127.         return compiled_parent._render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/base.py" in _render
  117.         return self.nodelist.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/usr/local/lib64/python2.6/site-packages/django/template/debug.py" in render_node
  73.             result = node.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/loader_tags.py" in render
  64.             result = block.nodelist.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/usr/local/lib64/python2.6/site-packages/django/template/debug.py" in render_node
  73.             result = node.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/defaulttags.py" in render
  313.             return self.nodelist_false.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/usr/local/lib64/python2.6/site-packages/django/template/debug.py" in render_node
  73.             result = node.render(context)
File "/usr/local/lib64/python2.6/site-packages/django/template/defaulttags.py" in render
  437.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in reverse
  391.             *args, **kwargs)))
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in reverse
  312.         possibilities = self.reverse_dict.getlist(lookup_view)
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in _get_reverse_dict
  229.             self._populate()
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in _populate
  208.                     for name in pattern.reverse_dict:
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in _get_reverse_dict
  229.             self._populate()
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in _populate
  220.                 lookups.appendlist(pattern.callback, (bits, p_pattern))
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in _get_callback
  164.             self._callback = get_callable(self._callback_str)
File "/usr/local/lib64/python2.6/site-packages/django/utils/functional.py" in wrapper
  124.         result = func(*args)
File "/usr/local/lib64/python2.6/site-packages/django/core/urlresolvers.py" in get_callable
  91.                 lookup_view = getattr(import_module(mod_name), func_name)
File "/usr/local/lib64/python2.6/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)

File "/usr/lib64/python2.6/logging/__init__.py" in __init__
  790.             stream = self._open()
File "/usr/lib64/python2.6/logging/__init__.py" in _open
  810.             stream = open(self.baseFilename, self.mode)

Exception Type: TemplateSyntaxError at /
Exception Value: Caught IOError while rendering: (13, 'Permission denied')

这是什么意思?我怎么解决呢?

2 个答案:

答案 0 :(得分:1)

通常这可能是渲染时的文件权限问题

对您的模板目录执行chmod 777 -R

或者你升级了django版本了吗?

答案 1 :(得分:0)

用户,Apache正在运行,没有权限写入/ tmp /目录。

我建议的方法是:

  • 将Apache作为非root用户下的守护进程的代理运行。
  • 将日志文件夹从/ tmp /更改为/ tmp中的某个子文件夹,例如/ tmp / projectname
  • 添加apache用户,写入 文件夹的权限。