本文整理匯總了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")