在我正在构建的网站上,用户有 1 个具有多个配置文件的帐户。当用户登录时,它会将与该帐户关联的所有配置文件加载到会话中,以便在视图中显示所有配置文件的信息等。我刚刚将该字段添加bookmarks
到 Profile 类中。当我登录时,我收到一个错误no such table: users_profile_bookmarks
,并且该行在profile = model_to_dict(profile)
回溯中突出显示。
我正在使用 south 来管理数据库迁移,并且迁移工作正常。我什./manage.py shell
至可以创建、读取和删除 的实例Profile
,但是当我尝试将配置文件添加到bookmarks
shell 中的字段时,我得到了同样的错误。
以下是模型:
from django.db import models
class Account(models.Model):
username = models.CharField(max_length=20)
email = models.CharField(max_length=100)
password = models.CharField(max_length=100)
viewed = models.ManyToManyField('Profile', null=True, blank=True, related_name='viewed_profiles')
visitors = models.ManyToManyField('Profile', null=True, blank=True, related_name='visitors_profiles')
class Profile(models.Model):
field1 = models.CharField(max_length=25)
field2 = models.IntegerField()
account = models.ForeignKey('Account', null=True, blank=True)
links = models.ManyToManyField('self', null=True, blank=True, related_name='links')
bookmarks = models.ManyToManyField('self', null=True, blank=True, related_name='bookmarks')