Wagtail 0.8.6 - 管理员 - NoneType' 对象没有属性 'allowed_subpage_types'
Wagtail 0.8.6 - admin - NoneType' object has no attribute 'allowed_subpage_types'
当我尝试访问管理中的特定页面时,我将 Wagtail 0.8.6 与 Django 1.7.7 一起使用:
http://127.0.0.1:8020/admin/pages/4/
我收到以下错误:
AttributeError at /admin/pages/4/
'NoneType' object has no attribute 'allowed_subpage_types'
这是回溯:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8020/admin/pages/4/
Django Version: 1.7.7
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'raven.contrib.django.raven_compat',
'compressor',
'taggit',
'modelcluster',
'django.contrib.admin',
'preventconcurrentlogins',
'django_medusa',
'wagtail.wagtailcore',
'wagtail.wagtailadmin',
'wagtail.wagtaildocs',
'wagtail.wagtailsnippets',
'wagtail.wagtailusers',
'wagtail.wagtailimages',
'wagtail.wagtailembeds',
'wagtail.wagtailsearch',
'wagtail.wagtailredirects',
'wagtail.contrib.wagtailmedusa',
'myapp',
'django_extensions')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'preventconcurrentlogins.middleware.PreventConcurrentLoginsMiddleware',
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware')
Template error:
In template /home/vagrant/venv/local/lib/python2.7/site-packages/wagtail/wagtailadmin/templates/wagtailadmin/pages/list.html, error at line 265
'NoneType' object has no attribute 'allowed_subpage_types'
255 : {% if allow_navigation %}
256 : {% if moving %}
257 : {% if page.can_descend %}
258 : <a href="{% url 'wagtailadmin_pages_move_choose_destination' page_to_move.id page.id %}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.title %}Explorer subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
259 : {% endif %}
260 : {% elif choosing %}
261 : {% if page.can_descend %}
262 : <a href="{% url 'wagtailadmin_choose_page_child' page.id %}?{{ querystring }}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.title %}Explorer subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
263 : {% endif %}
264 : {% else %}
265 : {% if page.is_navigable %}
266 : <a href="{% url 'wagtailadmin_explore' page.id %}" class="icon text-replace icon-arrow-right" title="{% blocktrans with title=page.title %}Explore child pages of '{{ title }}'{% endblocktrans %}">{% trans "Explore" %}</a>
267 : {% elif page_perms.can_add_subpage %}
268 : <a href="{% url 'wagtailadmin_pages_add_subpage' page.id %}" class="icon text-replace icon-plus-inverse" title="{% blocktrans with title=page.title %}Add a child page to '{{ title }}'{% endblocktrans %}">{% trans 'Add subpage' %}</a>
269 : {% endif %}
270 : {% endif %}
271 : {% endif %}
272 : </td>
273 : </tr>
274 : {% endfor %}
275 : {% else %}
Traceback:
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/wagtail/wagtailadmin/views/pages.py" in index
65. 'pages': pages,
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/shortcuts.py" in render
50. return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
178. return t.render(context_instance)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
148. return self._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
150. return template.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
148. return self._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
312. return nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
201. nodelist.append(node.render(context))
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
312. return nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
312. return nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
305. match = condition.eval(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in eval
898. return self.value.resolve(context, ignore_failures=True)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in resolve
596. obj = self.var.resolve(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in resolve
734. value = self._resolve_lookup(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _resolve_lookup
788. current = current()
File "/home/vagrant/venv/local/lib/python2.7/site-packages/wagtail/wagtailcore/models.py" in can_add_subpage
1269. if not self.page.specific_class.allowed_subpage_types(): # this page model has an empty subpage_types list, so no subpages are allowed
Exception Type: AttributeError at /admin/pages/4/
Exception Value: 'NoneType' object has no attribute 'allowed_subpage_types'
在升级之前,Wagtail 0.5 和 Django 1.6.5 可以正常工作。
知道是什么原因造成的吗?
我今天也遇到了这个错误。
我在 wagtailcore models.py 文件中找到了这行代码,并添加了打印语句以缩小导致问题的页面范围。
def can_add_subpage(self):
print self
从那里我检查了数据库中的 wagtailcore_page table 并找到了特定的页面。在我的例子中,它指向不再使用的模型的内容类型,我相应地更新了数据库。
您也可以在 shell 中进行测试。
from wagtail.wagtailcore.models import Page
pages = Page.objects.all()
for p in pages:
if not p.specific_class:
print p
我在 CMS 中经常看到这种情况,您创建特定类型的页面,然后 delete/rename 模型,但旧数据保留在页面树中。在删除代码之前,我总是尝试确保先删除 CMS 中的那些内容类型。
希望这会为您指明正确的方向。鹡鸰。
谢谢!我通过以下方式解决了这个问题:
from wagtail.wagtailcore.models import Page
pages = Page.objects.all()
for p in pages:
if not p.specific_class:
p.delete()
当我尝试访问管理中的特定页面时,我将 Wagtail 0.8.6 与 Django 1.7.7 一起使用:
http://127.0.0.1:8020/admin/pages/4/
我收到以下错误:
AttributeError at /admin/pages/4/
'NoneType' object has no attribute 'allowed_subpage_types'
这是回溯:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8020/admin/pages/4/
Django Version: 1.7.7
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'raven.contrib.django.raven_compat',
'compressor',
'taggit',
'modelcluster',
'django.contrib.admin',
'preventconcurrentlogins',
'django_medusa',
'wagtail.wagtailcore',
'wagtail.wagtailadmin',
'wagtail.wagtaildocs',
'wagtail.wagtailsnippets',
'wagtail.wagtailusers',
'wagtail.wagtailimages',
'wagtail.wagtailembeds',
'wagtail.wagtailsearch',
'wagtail.wagtailredirects',
'wagtail.contrib.wagtailmedusa',
'myapp',
'django_extensions')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'preventconcurrentlogins.middleware.PreventConcurrentLoginsMiddleware',
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware')
Template error:
In template /home/vagrant/venv/local/lib/python2.7/site-packages/wagtail/wagtailadmin/templates/wagtailadmin/pages/list.html, error at line 265
'NoneType' object has no attribute 'allowed_subpage_types'
255 : {% if allow_navigation %}
256 : {% if moving %}
257 : {% if page.can_descend %}
258 : <a href="{% url 'wagtailadmin_pages_move_choose_destination' page_to_move.id page.id %}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.title %}Explorer subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
259 : {% endif %}
260 : {% elif choosing %}
261 : {% if page.can_descend %}
262 : <a href="{% url 'wagtailadmin_choose_page_child' page.id %}?{{ querystring }}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.title %}Explorer subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
263 : {% endif %}
264 : {% else %}
265 : {% if page.is_navigable %}
266 : <a href="{% url 'wagtailadmin_explore' page.id %}" class="icon text-replace icon-arrow-right" title="{% blocktrans with title=page.title %}Explore child pages of '{{ title }}'{% endblocktrans %}">{% trans "Explore" %}</a>
267 : {% elif page_perms.can_add_subpage %}
268 : <a href="{% url 'wagtailadmin_pages_add_subpage' page.id %}" class="icon text-replace icon-plus-inverse" title="{% blocktrans with title=page.title %}Add a child page to '{{ title }}'{% endblocktrans %}">{% trans 'Add subpage' %}</a>
269 : {% endif %}
270 : {% endif %}
271 : {% endif %}
272 : </td>
273 : </tr>
274 : {% endfor %}
275 : {% else %}
Traceback:
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/wagtail/wagtailadmin/views/pages.py" in index
65. 'pages': pages,
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/shortcuts.py" in render
50. return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
178. return t.render(context_instance)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
148. return self._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
150. return template.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
148. return self._render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
312. return nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
201. nodelist.append(node.render(context))
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
312. return nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
312. return nodelist.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
305. match = condition.eval(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py" in eval
898. return self.value.resolve(context, ignore_failures=True)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in resolve
596. obj = self.var.resolve(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in resolve
734. value = self._resolve_lookup(context)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/template/base.py" in _resolve_lookup
788. current = current()
File "/home/vagrant/venv/local/lib/python2.7/site-packages/wagtail/wagtailcore/models.py" in can_add_subpage
1269. if not self.page.specific_class.allowed_subpage_types(): # this page model has an empty subpage_types list, so no subpages are allowed
Exception Type: AttributeError at /admin/pages/4/
Exception Value: 'NoneType' object has no attribute 'allowed_subpage_types'
在升级之前,Wagtail 0.5 和 Django 1.6.5 可以正常工作。 知道是什么原因造成的吗?
我今天也遇到了这个错误。
我在 wagtailcore models.py 文件中找到了这行代码,并添加了打印语句以缩小导致问题的页面范围。
def can_add_subpage(self):
print self
从那里我检查了数据库中的 wagtailcore_page table 并找到了特定的页面。在我的例子中,它指向不再使用的模型的内容类型,我相应地更新了数据库。
您也可以在 shell 中进行测试。
from wagtail.wagtailcore.models import Page
pages = Page.objects.all()
for p in pages:
if not p.specific_class:
print p
我在 CMS 中经常看到这种情况,您创建特定类型的页面,然后 delete/rename 模型,但旧数据保留在页面树中。在删除代码之前,我总是尝试确保先删除 CMS 中的那些内容类型。
希望这会为您指明正确的方向。鹡鸰。
谢谢!我通过以下方式解决了这个问题:
from wagtail.wagtailcore.models import Page
pages = Page.objects.all()
for p in pages:
if not p.specific_class:
p.delete()