Django,UserProfile继承噩梦?

时间:2012-06-25 14:09:22

标签: sql django django-models django-admin django-registration

我同时使用django-userenadjango-facebook作为我的主要注册应用。

让我们继承自己的UserProlfile

from userena.models import UserenaBaseProfile
from django_facebook.models import FacebookProfileModel


class UserProfile(UserenaBaseProfile , FacebookProfileModel):
    user = models.OneToOneField(User, unique=True, verbose_name=_('user'), related_name='user_profile')
    department     = models.ForeignKey('Department' , null = True , blank = True , related_name=_('user'))
    name           = models.CharField(max_length = 100)
    birthday       = models.DateField()

    def __unicode__(self):
        return self.name

class Student(UserProfile):
    courses = models.ManyToManyField(Course , null = True, blank = True, related_name = _('student'))

现在,每当我想看看Django Admin中的学生时,我都会收到此错误:

Exception Value: No such column: profiles_userprofile.about_me

但是,它存在!!这是./manage.py sqlall profiles

的输出
BEGIN;
CREATE TABLE "profiles_userprofile" (
    "id" integer NOT NULL PRIMARY KEY,
    "mugshot" varchar(100) NOT NULL,
    "privacy" varchar(15) NOT NULL,

    "about_me" text, ## Her it is !!!

    "facebook_id" bigint UNIQUE,
    "access_token" text NOT NULL,
    "facebook_name" varchar(255) NOT NULL,
    "facebook_profile_url" text NOT NULL,
    "website_url" text NOT NULL,
    "blog_url" text NOT NULL,
    "image" varchar(255),
    "date_of_birth" date,
    "gender" varchar(1),
    "raw_data" text NOT NULL,
    "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id"),
    "department_id" integer,
    "name" varchar(100) NOT NULL,
    "birthday" date NOT NULL
)
;

我很困惑..任何人都可以给我一个提示吗?

1 个答案:

答案 0 :(得分:4)

如果您是第一次运行sqlall

syncdb仅告诉您发送的SQL。它为您提供数据库的实际状态。您必须实际运行syncdb才能创建表。此外,如果任何表格已经存在,syncdb对表格进行任何更改;它只创建表,永远不会改变它们。

如果您需要更改表,则必须在数据库上手动运行SQL,或使用South之类的内容进行迁移。