当前位置: 首页 > news >正文

手机端的网站怎么做crm系统

手机端的网站怎么做,crm系统,自驾游黄山风景区旅游攻略,用表格做的网站简记 使用 Django Shell 清空所有数据库表 jcLee95的博客:https://blog.csdn.net/qq_28550263 本文地址:https://blog.csdn.net/qq_28550263/article/details/132862795 目 录 1. 描述2. 步骤备份重要数据进入 Django Shell输入脚本 1. 描述 由于历史的…
简记
使用 Django Shell 清空所有数据库表

jcLee95的博客:https://blog.csdn.net/qq_28550263

本文地址:https://blog.csdn.net/qq_28550263/article/details/132862795



1. 描述

由于历史的迁移历史的混乱状态导致尝试运行 python manage.py migrate 时,Django 试图创建数据库表时发生了问题。错误信息中提到了缺少 django_content_type 表,这是Django用于跟踪模型的ContentType的表。

错误大致信息如下:

Operations to perform:Apply all migrations: admin, auth, contenttypes, sessions, users
Running migrations:No migrations to apply.
Traceback (most recent call last):File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 89, in _executereturn self.cursor.execute(sql, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\sqlite3\base.py", line 357, in executereturn Database.Cursor.execute(self, query, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such table: django_content_typeThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "D:\desktop\jcmusic\manage.py", line 22, in <module>main()File "D:\desktop\jcmusic\manage.py", line 18, in mainexecute_from_command_line(sys.argv)File "C:\Python311\Lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_lineutility.execute()File "C:\Python311\Lib\site-packages\django\core\management\__init__.py", line 440, in executeself.fetch_command(subcommand).run_from_argv(self.argv)File "C:\Python311\Lib\site-packages\django\core\management\base.py", line 402, in run_from_argvself.execute(*args, **cmd_options)File "C:\Python311\Lib\site-packages\django\core\management\base.py", line 448, in executeoutput = self.handle(*args, **options)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\core\management\base.py", line 96, in wrappedres = handle_func(*args, **kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\core\management\commands\migrate.py", line 376, in handleemit_post_migrate_signal(File "C:\Python311\Lib\site-packages\django\core\management\sql.py", line 52, in emit_post_migrate_signalmodels.signals.post_migrate.send(File "C:\Python311\Lib\site-packages\django\dispatch\dispatcher.py", line 176, in sendreturn [^File "C:\Python311\Lib\site-packages\django\dispatch\dispatcher.py", line 177, in <listcomp>(receiver, receiver(signal=self, sender=sender, **named))^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\contrib\auth\management\__init__.py", line 51, in create_permissionscreate_contenttypes(File "C:\Python311\Lib\site-packages\django\contrib\contenttypes\management\__init__.py", line 127, in create_contenttypescontent_types, app_models = get_contenttypes_and_models(^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\contrib\contenttypes\management\__init__.py", line 98, in get_contenttypes_and_modelscontent_types = {^File "C:\Python311\Lib\site-packages\django\db\models\query.py", line 394, in __iter__self._fetch_all()File "C:\Python311\Lib\site-packages\django\db\models\query.py", line 1867, in _fetch_allself._result_cache = list(self._iterable_class(self))^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\models\query.py", line 87, in __iter__results = compiler.execute_sql(^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\models\sql\compiler.py", line 1398, in execute_sqlcursor.execute(sql, params)File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 102, in executereturn super().execute(sql, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 67, in executereturn self._execute_with_wrappers(^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 80, in _execute_with_wrappersreturn executor(sql, params, many, context)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 84, in _executewith self.db.wrap_database_errors:File "C:\Python311\Lib\site-packages\django\db\utils.py", line 91, in __exit__raise dj_exc_value.with_traceback(traceback) from exc_valueFile "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 89, in _executereturn self.cursor.execute(sql, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\sqlite3\base.py", line 357, in executereturn Database.Cursor.execute(self, query, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: no such table: django_content_type

我决定使用 Django Shell 清空数据库表。记录一下过程。

2. 步骤

备份重要数据

清理前,确保你使用各种手段备份过了所有重要数据,然后才清空数据库中的所有表。

进入 Django Shell

python manage.py shell

输入脚本

拷贝以下写好的删表脚本到交互式Shell中,键入回车开始执行。

from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()
for table in tables:cursor.execute(f"DELETE FROM {table[0]};")

然后输入exit函数退出该Django Shell环境。

exit()

可以了,现在可以重新创建迁移和数据库表了:

python manage.py makemigrations
python manage.py migrate
http://www.yayakq.cn/news/386695/

相关文章:

  • 如何高效建设品牌网站静态网站如何添加关键词
  • 烟台教育网站建设wordpress 点击量
  • 桂林北站到阳朔软件开发专业适合女生吗
  • 它是企业整体网站seo策划方案
  • 网站服务器的作用和功能有哪些网站首页缩略图 seo
  • 图书销售网站建设爱站网是干什么的
  • 好网站制作公司有哪些设计公司起名怎么起好
  • 徐州网站建设托管外网域名购买
  • 电力建设集团网站汕头市平台网络推广公叿
  • 响应式企业网站cms在线画流程图的网站
  • 纯html5 网站网站建设是一项系统工程
  • 怎么做网络销售的网站企业网络是指
  • 新视网站建设联系qq彩云小梦ai写作网站
  • 网络编程和网站建设联系建微信网站模板
  • 新手做网站流程腾讯云建站多少钱
  • 公司主页网站怎么做通用集团网站模板
  • dede关闭网站网站301做下
  • 新开传奇最大网站999代做网站关键词
  • 哪个网站做推销产品天猫官方网站首页
  • 青海网站制作多少钱域名还在备案可以做网站吗
  • 网站关键词字数wordpress 发布文章
  • 海口网站运营托管费用php访问网站
  • 深圳建设材料价格网站筹备网站建设
  • 广州建设六马路小学网站互联网企业包括哪些行业
  • 培训制作网站源码网页制作框架模板的步骤
  • 网站缺点高端建设网站公司哪家好
  • 建设手机网站的目的鲜花网站数据库建设分析
  • 网站后台 更新缓存织梦网站登录
  • 做团餐的企业网站比较好约的网站设计
  • 承德企业网站建设公司域名备案完成了怎么建设网站