我有一个带有 GenericForeignKey 的模型:
class Breadcrumbs( models.Model ):
title = models.CharField( max_length = 256 )
limit = models.Q( app_label = 'news', model = 'NewsPost' )
content_type = models.ForeignKey( ContentType, limit_choices_to = limit )
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey( 'content_type', 'object_id' )
class Meta:
db_table = 'breadcrumbs'
默认情况下,object_id 有一个输入文本小部件:
如何使其成为带有选项的选择?我也想默认用NewsPost ids(或NewsPost的unicode())填充它。