我有以下模型和序列化程序:
class SeminarTracking(models.Model):
id = models.BigIntegerField(primary_key=True)
id_tax_seminar = models.BigIntegerField(null=True, blank=True)
cid = models.ForeignKey('clients.Client')
invite = models.IntegerField(null=True, blank=True)
invite_2 = models.IntegerField(null=True, blank=True)
rsvp = models.CharField(max_length=255L, blank=True)
attendees = models.IntegerField(null=True, blank=True)
names = models.CharField(max_length=255L, blank=True)
notes = models.TextField(blank=True)
class Meta:
db_table = 'tax_seminars_tracking'
class SeminarTrackingSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = SeminarTracking
客户端序列化:
class ClientSerializer(serializers.HyperlinkedModelSerializer):
#adwebsite = serializers.PrimaryKeyRelatedField()
#adissue = serializers.PrimaryKeyRelatedField(required=False)
#category = serializers.PrimaryKeyRelatedField(many=True)
status = serializers.Field()
seminars = SeminarTrackingSerializer(source='seminartracking_set')
class Meta:
model = Client
每当我通过 API 访问客户端时,都会出现以下错误:
(1054, "Unknown column 'tax_seminars_tracking.cid_id' in 'field list'")
如果我seminartracking_set
在视图或模板中访问,它没有问题。有什么我想念的吗?- 注意客户端模型的主键是clientid
, not id
- 不确定这是否相关。
非常感谢,本