我想重置我的 Django 项目的数据库,所以我做了以下步骤:
- 删除了我的 SQLite 数据库
- 做过
python manage.py syncdb
- 做过
python manage.py migrate users --fake
创建新帐户并登录后,我收到以下错误消息:
no such table: users_userprofile
这是我的用户 model.py 的样子:
class UserProfile(models.Model):
user = models.OneToOneField(User)
joined_goals = models.ManyToManyField(Goal, related_name="joined_goals")
followingGoals = models.ManyToManyField(Goal, related_name="following_goals")
def __unicode__(self):
return self.user.username
def get_goals(self):
try:
goals = Goal.objects.filter(user=self.user)
return goals
except Goal.DoesNotExist:
return []
def create_user_profile(sender, instance, created, **kwargs):
if created:
userProfile = UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
所以,有一个 UserProfile 类,但 South 似乎没有制作表格来保存用户配置文件。当我这样做时python manage.py schemamigration users --auto
,它说似乎没有任何改变。如何获得它来创建 userprofiles 表?