且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

django中的自定义用户模型1.5

更新时间:2023-12-02 08:11:58

看起来非常像一个(PostgreSQL)数据库错误 - 不是Django错误。 (auth_user)在数据库结构中的ForeignKey约束中被引用(仍然)。这样的事情不应该存在于您的自定义模型中,这被称为MyUser。在这种情况下,引用应该是accounts_myuser或myappname_myuser。

This looks very much like a (PostgreSQL) database error - not a Django error. "auth_user" is (still) referenced in a ForeignKey constraint in your database structure. Such a thing shouldn't exist with your custom model, which is called "MyUser". In this case, the reference should be something like "accounts_myuser" or "myappname_myuser".

我猜,你已经更新了一个已经存在的代码,包括一个旧的数据库。如果您不需要旧的管理员日志,只需删除/删除名为django_admin_log的表,然后运行python manage.py syncdb(或python manage.py migrate,为1.7),让Django重新创建

I guess, you've updated an already existing code including an old database. If you don't need the old admin logs, simply delete/drop the table called "django_admin_log" and then run "python manage.py syncdb" (or "python manage.py migrate" as of 1.7) to let Django re-create this table from scratch.

尽管如此,如果您有其他表格引用了旧Django用户模型,那么您将再次运行同样的问题在其他地方。

Be careful, though: If you have other tables referencing the "old" Django User model, you'll run again into the same kind of trouble in other locations.