models.py
我的 Django 项目中有以下模型( ):
class Topic(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=140)
def __unicode__(self):
return self.title
class ArgumentElement(models.Model):
id = models.AutoField(primary_key=True)
contents = models.CharField(max_length=256)
elementType = models.CharField(max_length=10)
topic = models.ForeignKey(Topic, related_name='ArgumentElement_Topic')
def __unicode__(self):
return self.contents
class ArgumentElementConnection(models.Model):
id = models.AutoField(primary_key=True)
sourceId = models.ForeignKey(ArgumentElement, related_name='connection_source')
targetId = models.ForeignKey(ArgumentElement, related_name='connection_target')
topic = models.ForeignKey(Topic, related_name='ArgumentElementConnection_Topic')
connectionType = models.CharField(max_length=7)
def __unicode__(self):
return self.id
我将所有三个模型添加到管理员(admin.py
):
from django.contrib import admin
from history_site.opinions.models import ArgumentElement, ArgumentElementConnection, Topic
admin.site.register(ArgumentElement, admin.ModelAdmin)
admin.site.register(ArgumentElementConnection, admin.ModelAdmin)
admin.site.register(Topic, admin.ModelAdmin)
当我创建一个实例Topic
然后尝试在管理员中删除它时,我收到错误no such column: opinions_argumentelement.topic_id
。
我的怎么了models.py
?