我正在使用contenttypes框架在我的网站上创建一个“特色内容”功能。我基本上是这样定义一个模型的:
class FeaturedContent(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
我现在想做的是在我的管理区域内的每个模型编辑/创建页面上都有一个勾选框,当勾选并提交时,它会将内容引用添加到FeaturedContent。取消勾选时,引用也会被删除。你知道吗
如果有更好的方法,请让我知道。在我看来,使用contenttypes是一个不错的选择。你知道吗
非常感谢!你知道吗
您将需要创建一个StackedLine管理,为您的每个模型,需要在管理中的这个选项。你知道吗
如下所示:
但是这将在默认小部件中提供内联线,因此您还需要定义一个表单来定制checkbox小部件。你知道吗
相关问题 更多 >
编程相关推荐