我在django-sitetree项中添加了一些自定义字段,需要通过视图和模板进行访问。
Django-Sitetree模板标记{%load sitetree%}使我可以访问标准站点树字段,即{%maintree“%}中的sitetree_page_description,但我不知道如何显示我的自定义字段之一。 / p>
我的自定义模型如下:
class MyCustomSiteSection(TreeItemBase):
"""This is your site item model.
"""
tag_set = TaggableManager( 'Tags', help_text="What tags should be used for content in this section?", blank=True )
template = models.ForeignKey( Template, help_text="What template should be used to render this section?", on_delete=models.CASCADE )
is_edited = models.BooleanField( help_text="Is this section human controlled or simply a list of content?" )
我认为,我尝试过:
current_tree_item_class = get_tree_item_model() # MyTreeItem from myapp.models (from the example above)
test = current_tree_item_class.is_edited
但是在页面上,我得到:
<django.db.models.query_utils.DeferredAttribute object at 0x10e1a9438>