本地转储数据问题(在 django app-engine-patch 上)

发布于 2024-08-08 13:12:47 字数 469 浏览 4 评论 0原文

我正在将 django 与 app-engine-patch 一起使用,并且在从本地存储运行 manage.py dumpdata 时遇到了这个奇怪的问题(当我使用 --remote 选项时工作正常)

我正在运行一个本地开发服务器,该服务器有一些对其进行测试数据。我可以在管理网站上看到该数据。 然而,运行manage.py dumpdata我得到的只是这样:

[{"pk": "agZmaWRkbWVyEQsSC2RqYW5nb19zaXRlGAEM", "model": "sites.site", "fields": {"domain": "example.com", "name": "example.com"}}]

它甚至与我正在做的事情无关。就好像在运行manage.py dumpdata时,它加载一个新的dev_appserver,该服务器从某个不是默认存储的未知位置读取数据。

知道这个转储数据来自哪里吗?

I'm using django with app-engine-patch and I'm having this wierd problem running manage.py dumpdata from local store (works fine when I use the --remote option)

I'm running a local development server that has some test data on it. I can see that data on the admin site.
However running manage.py dumpdata all I get is this:

[{"pk": "agZmaWRkbWVyEQsSC2RqYW5nb19zaXRlGAEM", "model": "sites.site", "fields": {"domain": "example.com", "name": "example.com"}}]

Its not even related to what I'm working on. As if when running manage.py dumpdata, it loads a new dev_appserver that reads data from some unknown location that's not the default store.

Any idea where this dumpdata comes from?

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

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

发布评论

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

评论(1

情魔剑神 2024-08-15 13:12:47

问题是 app-engine-patch manage.py 使用的数据存储路径与运行 dev_appserver.py 时使用的默认路径不同。

值为:

  • %TEMP%\dev_appserver.datastore
  • %TEMP%\dev_appserver.datastore.history

默认 使用:

  • %TEMP%\django_.datastore
  • %TEMP%\django_.datastore.history

这可以通过项目设置进行自定义。
负责这种差异的函数位于\django\db\backends\appengine\base.py:

def get_datastore_paths(settings_dict):
  """Returns a tuple with the path to the datastore and history file.

  The datastore is stored in the same location as dev_appserver uses by
  default, but the name is altered to be unique to this project so multiple
  Django projects can be developed on the same machine in parallel.

  Returns:
    (datastore_path, history_path)
  """
  from google.appengine.tools import dev_appserver_main
  options = settings_dict['DATABASE_OPTIONS']
  datastore_path = options.get('datastore_path',
      dev_appserver_main.DEFAULT_ARGS['datastore_path'].replace(
          "dev_appserver", "django_%s" % appid))
  history_path = options.get('history_path',
      dev_appserver_main.DEFAULT_ARGS['history_path'].replace(
          "dev_appserver", "django_%s" % appid))
  return datastore_path, history_path

The problem it app-engine-patch manage.py uses a different datastore path than the defualt path used when running dev_appserver.py

The default is:

  • %TEMP%\dev_appserver.datastore
  • %TEMP%\dev_appserver.datastore.history

The manage.py uses:

  • %TEMP%\django_.datastore
  • %TEMP%\django_.datastore.history

This can be customized via the project settings.
The function that is incharge of this difference is in\django\db\backends\appengine\base.py:

def get_datastore_paths(settings_dict):
  """Returns a tuple with the path to the datastore and history file.

  The datastore is stored in the same location as dev_appserver uses by
  default, but the name is altered to be unique to this project so multiple
  Django projects can be developed on the same machine in parallel.

  Returns:
    (datastore_path, history_path)
  """
  from google.appengine.tools import dev_appserver_main
  options = settings_dict['DATABASE_OPTIONS']
  datastore_path = options.get('datastore_path',
      dev_appserver_main.DEFAULT_ARGS['datastore_path'].replace(
          "dev_appserver", "django_%s" % appid))
  history_path = options.get('history_path',
      dev_appserver_main.DEFAULT_ARGS['history_path'].replace(
          "dev_appserver", "django_%s" % appid))
  return datastore_path, history_path
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文