2024-05-15 10:59:52 发布
网友
我有两个问题:
这是我的代码,但不成功:
Reporter.objects.delete()
管理者内部:
def delete_everything(self): Reporter.objects.all().delete() def drop_table(self): cursor = connection.cursor() table_name = self.model._meta.db_table sql = "DROP TABLE %s;" % (table_name, ) cursor.execute(sql)
根据最新的documentation,正确的调用方法是:
Reporter.objects.all().delete()
如果要从所有表中删除所有数据,可能需要尝试命令python manage.py flush。这将删除表中的所有数据,但表本身仍将存在。
python manage.py flush
请在此处查看更多信息:https://docs.djangoproject.com/en/1.8/ref/django-admin/
管理者内部:
根据最新的documentation,正确的调用方法是:
如果要从所有表中删除所有数据,可能需要尝试命令
python manage.py flush
。这将删除表中的所有数据,但表本身仍将存在。请在此处查看更多信息:https://docs.djangoproject.com/en/1.8/ref/django-admin/
相关问题 更多 >
编程相关推荐