本文整理汇总了Python中feincms.module.blog.models.Entry.add_to_class方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.add_to_class方法的具体用法?Python Entry.add_to_class怎么用?Python Entry.add_to_class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feincms.module.blog.models.Entry
的用法示例。
在下文中一共展示了Entry.add_to_class方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Category
# 需要导入模块: from feincms.module.blog.models import Entry [as 别名]
# 或者: from feincms.module.blog.models.Entry import add_to_class [as 别名]
'feincms.module.extensions.ct_tracker',
'feincms.module.extensions.seo',
'feincms.module.extensions.changedate',
'feincms.module.extensions.seo', # duplicate
'feincms.module.page.extensions.navigation',
'feincms.module.page.extensions.symlinks',
'feincms.module.page.extensions.titles',
)
@python_2_unicode_compatible
class Category(MPTTModel):
name = models.CharField(max_length=20)
slug = models.SlugField()
parent = models.ForeignKey('self', blank=True, null=True,
related_name='children')
class Meta:
ordering = ['tree_id', 'lft']
verbose_name = 'category'
verbose_name_plural = 'categories'
def __str__(self):
return self.name
# add m2m field to entry so it shows up in entry admin
Entry.add_to_class('categories',
models.ManyToManyField(Category, blank=True, null=True))
EntryAdmin.list_filter += ('categories',)
示例2: Reporter
# 需要导入模块: from feincms.module.blog.models import Entry [as 别名]
# 或者: from feincms.module.blog.models.Entry import add_to_class [as 别名]
Page.create_content_type(Triple, regions=("main", "bottom"))
Page.create_content_type(Simple, regions=("main", "bottom"))
Page.create_content_type(Single)
Page.create_content_type(Advertisment)
Entry.create_content_type(Simple)
class Reporter(models.Model):
full_name = models.CharField(max_length=100, blank=False)
def __unicode__(self):
return self.full_name
# add m2m field to entry so it shows up in entry admin
Entry.add_to_class("categories", models.ManyToManyField(Category, blank=True, null=True))
Entry.add_to_class("reporters", models.ManyToManyField(Reporter, blank=True, null=True))
EntryAdmin.list_filter += ("categories", "reporters")
class Application(models.Model):
"""
Application object set general settings for the website,
such as background image, favicon, facebook group etc.
"""
title = models.CharField(max_length=255, blank=False, null=False)
logo = MediaFileForeignKey(MediaFile, blank=True, null=True)
favicon = MediaFileForeignKey(MediaFile, blank=True, null=True, related_name="as_favicon")
background_image = MediaFileForeignKey(MediaFile, blank=True, null=True, related_name="as_background_image")
ad_image = MediaFileForeignKey(MediaFile, blank=True, null=True, related_name="as_ad_image")