【问题标题】:Problem with local dumpdata (on django app-engine-patch)本地转储数据问题(在 django app-engine-patch 上)
【发布时间】:2010-12-08 09:45:04
【问题描述】:

我正在使用带有 app-engine-patch 的 django,但我在从本地商店运行 manage.py dumpdata 时遇到了这个奇怪的问题(当我使用 --remote 选项时工作正常)

我正在运行一个本地开发服务器,上面有一些测试数据。我可以在管理站点上看到该数据。 但是运行 manage.py dumpdata 我得到的只是:

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

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

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

【问题讨论】:

    标签: django google-app-engine app-engine-patch


    【解决方案1】:

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

    默认为:

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

    manage.py 使用:

    • %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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-04
      • 1970-01-01
      • 1970-01-01
      • 2010-11-09
      • 1970-01-01
      • 2011-03-28
      相关资源
      最近更新 更多