Django / Wagtail试图创建泛型子类

时间:2017-10-17 03:31:16

标签: python django wagtail

我正在开发一个Django / Wagtail应用程序,我正在尝试在我的模型中创建通用的,可重用的组件。我正在尝试按照内置Image类的工作方式,因为它们可以附加到任何其他对象类型。 但是我一直收到错误:

SELECT STUFF(CONCAT
(
    CASE WHEN Home = 1 THEN ', Own Home' END, 
    CASE WHEN Car = 1 THEN ', Car' END, 
    CASE WHEN Friend = 1 THEN ', Someone else''s home' END,
    CASE WHEN Toilet = 1 THEN ', Toilet' END,
    CASE WHEN Street = 1 THEN ', Street, park or beach' END,
    CASE WHEN Squat = 1 THEN ', Squat' END,
    CASE WHEN Other = 1 THEN ', Other' END
),1,2,'') 
as 'Question 6',
from table

以下是我的模型代码:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f78b26ad8c8>
Traceback (most recent call last):
  File "/.../runtime/lib/python3.4/site-packages/Django-1.8.14-py3.4.egg/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/.../runtime/lib/python3.4/site-packages/Django-1.8.14-py3.4.egg/django/core/management/commands/runserver.py", line 114, in inner_run
    self.validate(display_num_errors=True)
  File "/.../runtime/lib/python3.4/site-packages/Django-1.8.14-py3.4.egg/django/core/management/base.py", line 469, in validate
    return self.check(app_configs=app_configs, display_num_errors=display_num_errors)
  File "/.../runtime/lib/python3.4/site-packages/Django-1.8.14-py3.4.egg/django/core/management/base.py", line 482, in check
    include_deployment_checks=include_deployment_checks,
  File "/.../runtime/lib/python3.4/site-packages/Django-1.8.14-py3.4.egg/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/.../runtime/lib/python3.4/site-packages/wagtail/wagtailadmin/checks.py", line 64, in get_form_class_check
    edit_handler = cls.get_edit_handler()
  File "/.../runtime/lib/python3.4/site-packages/wagtail/utils/decorators.py", line 55, in __call__
    return self.value
  File "/.../runtime/lib/python3.4/site-packages/Django-1.8.14-py3.4.egg/django/utils/functional.py", line 59, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/.../runtime/lib/python3.4/site-packages/wagtail/utils/decorators.py", line 51, in value
    return self.fn(self.cls)
  File "/.../runtime/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 824, in get_edit_handler
    return EditHandler.bind_to_model(cls)
  File "/.../runtime/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 334, in bind_to_model
    'children': [child.bind_to_model(model) for child in self.children],
  File "/.../runtime/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 334, in <listcomp>
    'children': [child.bind_to_model(model) for child in self.children],
  File "/.../runtime/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 354, in bind_to_model
    'children': [child.bind_to_model(model) for child in self.children],
  File "/.../runtime/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 354, in <listcomp>
    'children': [child.bind_to_model(model) for child in self.children],
  File "/.../runtime/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 754, in bind_to_model
    related = getattr(model, self.relation_name).related
AttributeError: 'ReverseSingleRelatedObjectDescriptor' object has no attribute 'related'

我要做的是使下载对象不仅可以访问Container模型,还可以访问其他模型。

0 个答案:

没有答案