我越來越從生產服務器這個錯誤:找不到原因「類型錯誤:強迫爲Unicode:需要字符串或緩衝區,NoneType發現」
File "/home/example/svn/libs/django/core/handlers/base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/example/svn/src/app/../app/libs/auth/decorators.py", line 125, in __call__
return self.view_func(request, *args, **kwargs)
File "/home/example/svn/src/app/../app/membership/decorators.py", line 64, in __call__
return self.view_func(request, *args, **kwargs)
File "/home/example/svn/src/app/../app/site/views/system/invoices.py", line 168, in send_via_email_form
return SendViaEmailFormPage(request, pk, what, sending_type).custom()
File "/home/example/svn/src/app/../app/security/security.py", line 99, in execute
return func(*args, **kw)
File "/home/example/svn/src/app/../app/site/views/system/invoices.py", line 405, in custom
return self.custom_response or self.response()
File "/home/example/svn/src/app/../app/security/security.py", line 99, in execute
return func(*args, **kw)
File "/home/example/svn/src/app/../app/libs/pages/__init__.py", line 235, in response
response = render_to_response(self.template, self.data, context_instance=RequestContext(self.request, self.data))
File "/home/example/svn/libs/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/home/example/svn/libs/django/template/loader.py", line 186, in render_to_string
return t.render(context_instance)
File "/home/example/svn/libs/django/template/__init__.py", line 173, in render
return self._render(context)
File "/home/example/svn/libs/django/template/__init__.py", line 167, in _render
return self.nodelist.render(context)
File "/home/example/svn/libs/django/template/__init__.py", line 796, in render
bits.append(self.render_node(node, context))
File "/home/example/svn/libs/django/template/__init__.py", line 809, in render_node
return node.render(context)
File "/home/example/svn/libs/django/template/__init__.py", line 849, in render
return _render_value_in_context(output, context)
File "/home/example/svn/libs/django/template/__init__.py", line 829, in _render_value_in_context
value = force_unicode(value)
File "/home/example/svn/libs/django/utils/encoding.py", line 66, in force_unicode
s = unicode(s)
TypeError: coercing to Unicode: need string or buffer, NoneType found
Unfortunely我不能在任何重現開發服務器上的方式。這個例外沒有什麼幫助。從Django中代碼:
if hasattr(s, '__unicode__'):
s = unicode(s)
如果爲何NoneType發現它具有 '的unicode' 屬性。我是否需要深入研究這個python源代碼?將不勝感激任何幫助。
謝謝。
我曾在一個項目中使用過Django。再也不。但在你的情況下,我建議你開始爲你的代碼編寫一些單元測試,你可能會發現這樣的問題。 – Keith