2017-04-20 99 views
0

我有兩個相同的代碼(開發和生產)的實例,我發現這個問題只發生在生產。我部署了一個處女例子,這意味着在那之前沒有W installation的安裝。在W Explorer的資源管理器不顯示任何頁面

W admin管理員顯示,我沒有網頁。我確實有2頁,即使我沒有,也不應該有「歡迎來到W Page頁」(它通常是,它在我的開發實例上)。此外,它看起來像是遺失了一部分網站。

enter image description here

這就是我所看到的,不管我有多少網頁創建(創建他們到達網址)

編輯: 這是在日誌中的完整的堆棧跟蹤

2017-04-21 10:27:08,898 exception 22370 ERROR Internal Server Error: /admin/pages/ 
Traceback (most recent call last): 
    File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 42, in inner 
    response = get_response(request) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response 
    response = self.process_exception_by_middleware(e, request) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response 
    response = wrapped_callback(request, *callback_args, **callback_kwargs) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/views/decorators/cache.py", line 43, in _cache_controlled 
    response = viewfunc(request, *args, **kw) 
    File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailadmin/decorators.py", line 24, in decorated_view 
    return view_func(request, *args, **kwargs) 
    File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailadmin/views/pages.py", line 104, in index 
    'do_paginate': do_paginate, 
    File "/opt/..../venv/lib/python3.5/site-packages/django/shortcuts.py", line 30, in render 
    content = loader.render_to_string(template_name, context, request, using=using) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader.py", line 68, in render_to_string 
    return template.render(context, request) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/backends/django.py", line 66, in render 
    return self.template.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 208, in render 
    return self._render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render 
    return self.nodelist.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render 
    bit = node.render_annotated(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated 
    return self.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render 
    return compiled_parent._render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render 
    return self.nodelist.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render 
    bit = node.render_annotated(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated 
    return self.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render 
    return compiled_parent._render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render 
    return self.nodelist.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render 
    bit = node.render_annotated(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated 
    return self.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render 
    return compiled_parent._render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render 
    return self.nodelist.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render 
    bit = node.render_annotated(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated 
    return self.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 70, in render 
    result = block.nodelist.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render 
    bit = node.render_annotated(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated 
    return self.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 70, in render 
    result = block.nodelist.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render 
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated 
    return self.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render 
    return compiled_parent._render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render 
    return self.nodelist.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render 
    bit = node.render_annotated(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated 
    return self.render(context) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/template/defaulttags.py", line 314, in render 
    if match: 
    File "/opt/..../venv/lib/python3.5/site-packages/django/core/paginator.py", line 112, in __len__ 
    return len(self.object_list) 
    File "/opt/..../venv/lib/python3.5/site-packages/django/db/models/query.py", line 238, in __len__ 
    self._fetch_all() 
    File "/opt/..../venv/lib/python3.5/site-packages/django/db/models/query.py", line 1087, in _fetch_all 
    self._result_cache = list(self.iterator()) 
    File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailcore/query.py", line 380, in specific_iterator 
    pages = model.objects.filter(pk__in=pks) 
AttributeError: 'NoneType' object has no attribute 'objects' 
+1

看起來在頁面上有一個模板錯誤,導致一個部分被無聲跳過(Django在生產模式下的默認行爲)。你可以嘗試在你的'TEMPLATES'設置中添加''debug':True'(按照https://gist.github.com/gasman/e0a9cb8c133db3e17c8e614e4fac883d),看看是否會給你提供更多信息錯誤? – gasman

+0

你說得對。錯誤是'AttributeError:'NoneType'對象沒有屬性'objects'',這實際上不是描述性的。從我能發現它來自'defaulttags.py',然後paginator拋出這個錯誤,因爲它沒有任何頁面去槽。 我可以發佈完整的回溯,但寧可將此對話轉換爲常規回答而非評論。 – Erika

+0

請編輯您的問題以包含完整的追溯。不幸的是,除非我有足夠的信息才能寫出一個答案,否則我們無法將此對話轉移到答案上.-) – gasman

回答

2

經過進一步調查後,我發現,當您從項目中刪除頁面模型定義時會發生此錯誤,但該類型的頁面仍然存在。 (W 012 應該能夠優雅地處理這種情況 - 事實上,它不是一個錯誤,我會立即提出問題...)

您可以通過運行以下行在./manage.py shell命令行:

from django.contrib.contenttypes.models import ContentType 

[(ct.id, ct.app_label, ct.model) for ct in ContentType.objects.all() if ct.model_class() is None and ct.app_label != 'wagtailadmin'] 

希望這將使得像一個結果:

[(2, u'home', u'homepage')] 

顯示缺頁類型的內容類型ID,應用標籤和型號名稱。

爲了讓管理工作再次,運行下面的行(確保從上述結果的內容類型ID替換2):

from wagtail.wagtailcore.models import Page 

Page.objects.filter(content_type_id=2).update(content_type=ContentType.objects.get(app_label='wagtailcore', model='page')) 

這將轉換相關頁面(S)爲鶺鴒的基本的「頁面」類型(其中沒有「標題」以外的內容字段) - 然後您可以繼續並刪除此頁面。

+0

事實上,這確實解決了我的問題。謝謝。你是否也可以發佈這個問題的鏈接,所以我可以留意一下這個問題,看看我能不能幫助一個PR。 – Erika

+0

很高興知道它的排序!問題是https://github.com/wagtail/wagtail/issues/3567,我現在有一個暫時的PR(等待審覈),網址是https://github.com/wagtail/wagtail/pull/3569。 – gasman

相關問題