我的django应用程序有问题。在django开发者服务器上它的工作完美,但是当我把它切换到apache时发生了一些奇怪的事情。让我们检查一下代码:
class Criteria(models.Model):
district = models.ManyToManyField(District, verbose_name=u"Województwo", blank=True)
respondents = models.ManyToManyField(User, verbose_name=u"Respondenci")
def getData(self):
# return self.district.all() - good
return self.respondents.all() # error
当我将settings.py调试变量设置为true(DEBUG = True)时,没有任何不良情况发生。但当我将其切换为false(DEBUG = False)时,我调用该方法时会出错。
MOD_PYTHON ERROR
ProcessId: 19463
Interpreter: 'www.panelbadawczy.pl'
ServerName: 'www.panelbadawczy.pl'
DocumentRoot: '/htdocs'
URI: '/edytuj-badanie,3/ustal-kryteria/'
Location: None
Directory: None
Filename: '/htdocs'
PathInfo: '/edytuj-badanie,3/ustal-kryteria/'
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.6/site-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.6/site-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.6/site-packages/django/core/handlers/modpython.py", line 228, in handler
return ModPythonHandler()(req)
File "/usr/lib/python2.6/site-packages/django/core/handlers/modpython.py", line 201, in __call__
response = self.get_response(request)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 134, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 166, in handle_uncaught_exception
return callback(request, **param_dict)
File "/usr/lib/python2.6/site-packages/django/views/defaults.py", line 24, in server_error
return http.HttpResponseServerError(t.render(Context({})))
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 178, in render
return self.nodelist.render(context)
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/usr/lib/python2.6/site-packages/django/template/loader_tags.py", line 97, in render
return compiled_parent.render(context)
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 178, in render
return self.nodelist.render(context)
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/usr/lib/python2.6/site-packages/django/template/loader_tags.py", line 24, in render
result = self.nodelist.render(context)
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 930, in render
resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 687, in resolve
value = self._resolve_lookup(context)
File "/usr/lib/python2.6/site-packages/django/template/__init__.py", line 740, in _resolve_lookup
raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute
VariableDoesNotExist: Failed lookup for key [user] in u"[{'block': <Block Node: loginBox. Contents: [<Text Node: '\r\n '>, <django.template.InclusionNode object at 0x91a002c>, <Text Node: '\r\n\t\t\t'>]>}, {}]"
有什么想法吗?
答案 0 :(得分:0)
如果我是你,我会调查这个块节点“loginBox”和必需参数'user'。