我正在使用 feinCMS 并将自定义内容添加到页面,并覆盖了自定义内容类中的渲染方法。渲染方法如下:
return render_to_string('badge/categories.html', {'categories', self}, context_instance=kwargs.get('context'))
badge/categories.html 模板中的代码是:
{% extends "feincms/base.html" %}
{% load feincms_page_tags %}
<h2> {{ feincms_page }}</h2>
{% for item in feincms_page.content.main %}
{{ item.render }}
{% endfor %}
页面的覆盖 url 是“/”。如果没有将自定义内容添加到页面,它可以正常工作,但是一旦我添加它,它就会引发以下错误:
Template error:
In template /home/yogesh/programs/bw-election-badges/apps/templates/includes/top_menu.html, error at line 4
'str' object has no attribute '_mptt_meta'
1 : {% load feincmsext_extended_navigation_tags feincms_page_tags mptt_tags%}
2 : <div class="nav-collapse collapse">
3 : <ul class="nav">
4 : {% feincms_nav feincms_page level=1 depth=3 as navitems %}
5 : {% with navitems|siblings_along_path_to:feincms_page as navtree %}
6 : {% recursetree navtree %}
7 : <li> <a href="{{ node.get_absolute_url }}">{{ node.short_title }}</a></li>
8 : {% if children %}
9 : <div style="margin-left: 20px">{{ children }}</div>
10 : {% endif %}
11 : {% endrecursetree %}
12 : {% endwith %}
13 : </ul>
14 : </div><!--/.nav-collapse -->
Traceback:
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
140. response = response.render()
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/response.py" in render
105. self.content = self.rendered_content
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
82. content = template.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
140. return self._render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
124. return compiled_parent._render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
63. result = block.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
156. return self.render_template(self.template, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render_template
138. output = template.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
140. return self._render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
54. result = self.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
188. nodelist.append(node.render(context))
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render
84. output = self.filter_expression.resolve(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in resolve
578. obj = self.var.resolve(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in resolve
728. value = self._resolve_lookup(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in _resolve_lookup
779. current = current()
File "/home/yogesh/programs/bw-election-badges/apps/project/badge/models.py" in render
33. return render_to_string('badge/detail.html', {'badge': self}, context_instance=kwargs.get('context'))
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
172. return t.render(Context(dictionary))
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
140. return self._render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
124. return compiled_parent._render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
63. result = block.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
156. return self.render_template(self.template, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render_template
138. output = template.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
140. return self._render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/django/template/base.py" in render
1146. context[self.target_var] = func(*resolved_args, **resolved_kwargs)
File "/home/yogesh/programs/env/local/lib/python2.7/site-packages/feincms/module/page/templatetags/feincms_page_tags.py" in feincms_nav
57. mptt_opts = feincms_page._mptt_meta
Exception Type: AttributeError at /
Exception Value: 'str' object has no attribute '_mptt_meta'