问题标签 [syncdb]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2429 浏览

django - post_syncdb 上不存在 ContentType 匹配查询

post_syncdb我正在尝试使用信号在创建表后立即向数据库添加一些数据。

然后在init函数中,我要设置权限,所以我用

但是,如果我放下所有桌子并运行syncdb,我会得到

我做过的一些测试:

  • 如果我在外面尝试这段代码,它工作正常syncdb
  • 如果我让syncdb创建没有此代码的所有表,然后添加此代码并运行 syncdb 而无需进行任何更改,它也可以正常工作。
  • 而且我很确定它曾经可以工作,但是从那以后我在其他地方改变了很多东西,所以我不知道从哪里开始。
  • 对于不同应用程序中的其他模型,我得到相同的错误。
  • 信号被触发大约 10 次,只有前几次抛出错误。

非常感谢任何提示!

0 投票
1 回答
1730 浏览

python - pycharm中的Django新syncdb超级用户崩溃

我在 Django 中创建新数据库时遇到问题:

我在那里读了很多消息,人们说它的语言环境有问题,但我检查了我的语言环境并且没问题:en_US.UTF-8

还能是什么?

Mac OS 10.8、Python 2.7.3、Django 1.4.1

谢谢

0 投票
0 回答
1762 浏览

python - Django:python manage.py syncdb 永远挂起

输出如下所示(项目名为parkingtickets):

然后它永远挂起。如果我暂停进程并杀死它,它不会死;我必须使用kill -9. 我以前从未遇到过这种情况 - 截至今天早上,我的应用程序运行顺利。我上次成功运行了 3 天前的 syncdb。那时我已经定义了更正,并且效果很好。我修改了模型以包含一个新字段 - 一个允许为空的不可编辑的外键 - 删除了表,然后点击了 syncdb。现在这个。我很乐意发布人们认为必要的任何信息。相关 settings.py(CRUD 是我们开发的一个内部框架,主要为我们加载通用模板):

编辑:好的,所以我添加的新外键会导致问题。任何其他表的外键都可以正常工作,并且对外键的修改不会改变任何内容(例如,上下移动它以便在不同的时间对其进行解析,使其可编辑,使其不接受空值)。这是我要外键进入的表的定义,Ticket:

0 投票
1 回答
392 浏览

python - 如果模型名称是应用程序名称,如何使 Django 模型不将应用程序的名称添加到模型中?

这就是正在发生的事情:

我启动了一个名为的应用程序cars并创建了一个名为Cars. 当我syncdb创建表时cars_cars。我怎样才能让它只创建表cars

另外,要补充一点,如果我有一个名为的应用程序cars和一个名为的模型car,但希望为该模型创建表,该cars怎么办?

0 投票
1 回答
1277 浏览

django - 在 django 中运行 syncdb 时找不到关系

我的 django 应用程序的 models.py 中有这些类。我使用 postgresql 8.3 作为数据库

当我运行时python manage.py syncdb,我收到一个错误,上面写着relation course is not found

更新: 我解决了这个问题如下

不过,我不太清楚为什么会发生这种行为。有人可以解释一下吗?

0 投票
1 回答
690 浏览

django - 安装 django-blog-zinnia

我正在浏览http://django-blog-zinnia.com/documentation/getting-started/install/的文档

当我同步数据库时,我收到此错误,标记在我安装的应用程序中,有人可以帮助我吗?

0 投票
1 回答
1270 浏览

django - 为 Django 教程同步 sqlite3

我正在启动 Django 教程并安装了虚拟环境和 django。我正在使用已经安装 sqlite3 的 Mac 10.6.8。

我在虚拟环境中工作。我将 settings.py 文件更改为:

NAME将 settings.py 文件中的 -- 留空(即''),因为教程说

“如果文件不存在,第一次同步数据库时会自动创建。”

但是当我运行时python manage.py syncdb,我收到以下错误:

django.core.exceptions.ImproperlyConfigured:使用数据库前请在设置模块中填写数据库名称。

为什么我的文件没有自动创建?或者我需要做什么来解决这个问题?

谢谢!

0 投票
1 回答
1448 浏览

mysql - Django-MySQL enable Row_Format=Compress with syncdb

I have an application in Django and MySQL, in my model I have several fields specified as TextField, when i run syncdb the tables for my model are created and the specified columns are created with longtext data type, so far so good.

But when I try, enter information in the table I get the following error

DatabaseError: (1118, 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs ")

I changed the column type to Text and Blob, and did not solve the problem.

I've been reading about this error and is due to more than 8126bytes income information by row. So I changed the configuration of MySQL to work with the file type Barracuda instead of Antepode, which I have been reading allows compression of sending information over to a different file.

But this did not solve the problem, in the MySQL documentation (https://dev.mysql.com/doc/refman/5.5/en/innodb-compression-usage.html) tells me that I have to specify ROW_FORMAT = COMPRESSED when i create the table, but this is done by syncdb,

Is there way to specify these settings when syncdb creates the tables or I have to create the tables manually without using syncdb?

Any other suggestions would be welcome, in my application I have to store multiple sheets and reports. I have defined a column in my table by section of the document.

0 投票
1 回答
3067 浏览

mysql - Django syncdb AttributeError:“list”对象没有属性“startswith”

一直无法找到解决方案。

模型.py

设置.py

这是引发的错误:

创建表 ... self.fetch_command(subcommand).run_from_argv(self.argv) 文件“C:\Python27\Lib\site-packages\django\core\management\base.py”,第 196 行,在 run_from_argv self.execute (*args, ** options.dict) 文件“C:\Python27\Lib\site-packages\django\core\management\base.py”,第 232 行,执行输出 = self.handle(*args, **options) 文件“C:\Python27\ Lib\site-packages\django\core\management\base.py”,第 371 行,在句柄中返回 self.handle_noargs(**options) 文件“C:\Python27\Lib\site-packages\django\core\management\ commands\syncdb.py”,第 91 行,在 handle_noargs sql 中,引用 = connection.creation.sql_create_model(model, self.style, seen_models) 文件“C:\Python27\Lib\site-packages\django\db\backends\creation .py",第 82 行,在 sql_create_model 样式中。SQL_TABLE(qn(opts.db_table)) + ' ('] 文件 "C:\Python27\Lib\site-packages\django\db\backends\mysql\base.py" ,第 244 行,在 quote_name 中,如果 name.startswith(" ") and name.endswith(""):AttributeError:“list”对象没有属性“startswith”

所以关键部分: AttributeError: 'list' object has no attribute 'startswith'

有人对我为什么会收到此错误有任何想法吗?我已经尝试了很多不同的东西,即使它成功地创建了其他表,它也不会工作它只是不会创建我的模型类。我正在使用 mysql 数据库。

0 投票
1 回答
1343 浏览

django - 将 django 站点移动到另一台服务器

我想将我的 django 站点移动到另一台机器上。(我想从空数据库开始)
我想我会完成以下步骤。

  • 复制所有文件

    设置所有工具(django、python、..等)

    运行同步数据库

当我运行时manage.py syncdb,它抱怨某些表(例如 django_content_type)不存在。
我查看了数据库,数据库中确实没有表。

我试过recreate project(startproject)或recreate app(startapp)。(但他们失败了,因为项目或应用程序名称已被占用。)

我应该怎么办?
我能想到的原因是mysql升级到5.5.27(默认为innodb)