Django REST 框架 + Django 管理数据保存

发布于 2025-01-10 10:56:25 字数 83 浏览 4 评论 0原文

我无法将其余 API 数据保存到另一个 Django 项目中。

如何将另一个 REST API 数据填充到我的 Django 管理数据库?

I am not able to save my rest API data to my another Django Project.

How I can populate another rest API data to my Django admin database ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵情客 2025-01-17 10:56:25

数据存储在数据库中,因此我假设您想要将数据传输到新数据库。

您可以通过以下方式进行操作。

  1. 首先清除您的新数据库 - (这里 new 是您的数据库的名称,它是默认的,但您可以在 settings.py 文件中查找它并使用该名称)

    python管理.py刷新--database=new

  2. 导出数据从旧数据库到 json 文件

    python Manage.py dumpdata>data.json

  3. 将数据加载到新数据库中

    python Manage.py loaddata data.json --database=new

您将旧数据库中的数据存储在新项目数据库中。

The data is stored in the database so I assume you want to transfer data to your new database.

You can do it in the following way.

  1. First clear your new database - (here new is the name of your database, it is default but you can look it up in settings.py file and use that name)

    python manage.py flush --database=new

  2. Export data from the old Database to a json file

    python manage.py dumpdata>data.json

  3. Load Data into the new Database

    python manage.py loaddata data.json --database=new

You have the data in your new project database from your old database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文