shipping 変数が none であるかどうかを確認しようとすると、型エラーが発生します (以下を参照)。フィールドはdjangoを使用して設定された通貨フィールドです...空かどうかを確認する正しい方法は何ですか。
Traceback (most recent call last):
File "core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "contrib/admin/options.py", line 307, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "views/decorators/cache.py", line 79, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "contrib/admin/sites.py", line 197, in inner
return view(request, *args, **kwargs)
File "admin.py", line 21, in changelist_view
return super(HeldOrderAdmin,self).changelist_view(request, extra_context=extra_context)
File "utils/decorators.py", line 28, in _wrapper
return bound_func(*args, **kwargs)
File "utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "utils/decorators.py", line 24, in bound_func
return func(self, *args2, **kwargs2)
File "contrib/admin/options.py", line 1179, in changelist_view
], context, context_instance=context_instance)
File "shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "template/loader.py", line 188, in render_to_string
return t.render(context_instance)
File "template/base.py", line 123, in render
return self._render(context)
File "template/base.py", line 117, in _render
return self.nodelist.render(context)
File "template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "template/base.py", line 757, in render_node
return node.render(context)
File "template/loader_tags.py", line 127, in render
return compiled_parent._render(context)
File "template/base.py", line 117, in _render
return self.nodelist.render(context)
File "template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "template/base.py", line 757, in render_node
return node.render(context)
File "template/loader_tags.py", line 127, in render
return compiled_parent._render(context)
File "template/base.py", line 117, in _render
return self.nodelist.render(context)
File "template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "template/base.py", line 757, in render_node
return node.render(context)
File "template/loader_tags.py", line 127, in render
return compiled_parent._render(context)
File "template/base.py", line 117, in _render
return self.nodelist.render(context)
File "template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "template/base.py", line 757, in render_node
return node.render(context)
File "template/loader_tags.py", line 64, in render
result = block.nodelist.render(context)
File "template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "template/base.py", line 757, in render_node
return node.render(context)
File "template/loader_tags.py", line 64, in render
result = block.nodelist.render(context)
File "template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "template/base.py", line 757, in render_node
return node.render(context)
File "template/base.py", line 921, in render
dict = func(*args)
File "contrib/admin/templatetags/admin_list.py", line 232, in result_list
'results': list(results(cl))}
File "contrib/admin/templatetags/admin_list.py", line 217, in results
yield ResultList(None, items_for_result(cl, res, None))
File "contrib/admin/templatetags/admin_list.py", line 209, in __init__
super(ResultList, self).__init__(*items)
File "contrib/admin/templatetags/admin_list.py", line 137, in items_for_result
f, attr, value = lookup_field(field_name, result, cl.model_admin)
File "contrib/admin/util.py", line 214, in lookup_field
value = attr(obj)
File "admin.py", line 50, in total
return '$%s' % (obj.order.total(),)
File "models.py", line 234, in total
if item.total is not None:
File "models.py", line 356, in total
shipping = 0
TypeError: unsupported operand type(s) for +: 'NoneType' and 'Decimal'