我有这个用户个人资料模型:
class UserProfile(models.Model):
user = models.OneToOneField(User, related_name='profile')
age = models.IntegerField(null = True)
location = models.CharField(max_length = 50, null = True, default ="")
display_name = models.CharField(max_length = 50, null = True, default ="")
updated_profile = models.BooleanField(default = False)
def __unicode__(self):
return "{}'s profile".format(self.user.username)
class Meta:
db_table = 'user_profile'
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
当我通过shell或代码尝试UserProfile.objects.all()
时,我得到了这个:
ProgrammingError: relation "user_profile" does not exist
LINE 1: ...play_name", "user_profile"."updated_profile" FROM "user_prof...
我在postgres中尝试过schemamigration,migrate,syncdb,删除并重新创建了整个数据库。还是一样的错误。
编辑:我也安装了django-allauth。我想这可能会干扰这种模式。