我试图将第三个类noticeTime
约束到外键email
。我使用的语法与第二个类location
的语法相同,但是当我在noticeTime
上使用它时,会抛出一个错误:
Exception Value: no such column: setupNotifications_noticetime.email_id
代码如下:
from django.db import models
# Create your models here.
from django.db import models
class email(models.Model):
email = models.CharField(max_length=200)
def __unicode__(self):
return self.email`
class location(models.Model):
email = models.ForeignKey(email)
zip_code = models.CharField(max_length=5)
def __unicode__(self):
return self.zip_code
class noticeTime(models.Model):
email = models.ForeignKey(email)
time = models.CharField(max_length=200)
def __unicode__(self):
return self.time
这里是管理员.py地址:
from django.contrib import admin
# Register your models here.
from setupNotifications.models import email
from setupNotifications.models import location
from setupNotifications.models import noticeTime
admin.site.register(email)
admin.site.register(location)
admin.site.register(noticeTime)
我正在使用sqlite数据库
也许您的问题是您运行了syncdb,假设它会改变表以匹配您的模型更改。不幸的是,它没有做到这一点。有一些单独的工具可用,例如South,它可以帮助进行数据库迁移。你知道吗
相关问题 更多 >
编程相关推荐