0
我的django應用程序出現問題。在Django開發人員服務器上它的工作非常完美,但是當我將它切換到Apache發生奇怪事情時。讓我們檢查代碼:django上的Mod_python和調試變量
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'>]>}, {}]"
任何想法?
你真的不應該使用mod-python。 mod-wsgi是要走的路。 – 2010-07-07 21:34:15
不幸的是,我不是公司的老闆,我不能這樣做。我需要使用mod_python。 – RykoS 2010-07-08 12:09:27