数据库错误:表 OmniCloud_App_user 没有名为 username 的列
所以我在尝试将用户添加到数据库时得到了这个。我想,我想知道它有哪些栏目?所以我要了sql...
DatabaseError: table OmniCloud_App_user has no column named username
>>>
root@Harold:~/OmniCloud/omnicloud# python manage.py sql OmniCloud_App
BEGIN;
CREATE TABLE "OmniCloud_App_user" (
"id" integer NOT NULL PRIMARY KEY,
"email" varchar(75) NOT NULL,
"username" varchar(25) NOT NULL,
"password" varchar(30) NOT NULL
)
;
嘿!就在那里!如果它实际上似乎已经说过了,为什么它会对下面的两行感到愤怒呢?
>>> u = User(email="[email protected]", username="gmail", password="gmail")
>>> u.save()
也不是我定义 User 类的方式,它说 user
没有名为 username 的列。为什么它变成小写?
So I got this when trying to add a User to the database. And I thought, I wonder what columns it does have? So I asked for the sql...
DatabaseError: table OmniCloud_App_user has no column named username
>>>
root@Harold:~/OmniCloud/omnicloud# python manage.py sql OmniCloud_App
BEGIN;
CREATE TABLE "OmniCloud_App_user" (
"id" integer NOT NULL PRIMARY KEY,
"email" varchar(75) NOT NULL,
"username" varchar(25) NOT NULL,
"password" varchar(30) NOT NULL
)
;
Hey! There it is! Why would it get mad at the two following lines if it seems to, in fact, have said column?
>>> u = User(email="[email protected]", username="gmail", password="gmail")
>>> u.save()
Also not how I am defining a User class and it says that user
has no column called username. Why does it go lowercase?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
$>吗? python 管理.py 同步数据库
?Syncdb 仅适用于新型号。您必须自己解决迁移问题,这就是 South 的用武之地。
或者,您可以自己修改数据库,或者使用另一个更接近该方法的应用程序,称为 nashvegas。
这是您所需的 SQL 的近似值。
$> python manage.py syncdb
?Syncdb only works on new models. You've got to sort out migrations yourself, and that's where South comes in.
Alternatively, you can modify the database on your own, or use another app, which is closer to that method, called nashvegas.
This is an approximation of the SQL that you need.
manage.py sql
给出了如果您现在要求syncdb
创建该表将会的 SQL。它不会向您显示表实际有什么 - 为此,您必须进入 db shell 并要求它为您描述该表。然后,您需要直接修改它或通过 South 等迁移工具进行修改。manage.py sql
gives the SQL that the table would have if you askedsyncdb
to create it now. It doesn't show you what the table actually has - for that you're going to have to go into your db shell and ask it to describe the table for you. Then, you'll need to modify it, either directly there or via a migration tool like South.