问题标签 [django-extensions]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
database - 在两个 django 服务器之间同步数据
我有一个中央 Django 服务器,其中包含我在数据库中的所有信息。我想要第二个 Django 服务器,它在第二个数据库中包含该信息的子集。我需要一种防弹方法来选择性地在两者之间同步数据。
- 辅助 Django 将需要在某些时候从主 Django 中提取其数据子集。该子集必须按某些字段进行过滤。
- 辅助 Django 必须偶尔将其数据推送到主 Django。
- 理想情况下,双向同步将为每个模型保留最近修改的对象。
我正在考虑使用 TimeStampedModel (来自 django-extensions)或添加我自己的 DateTimeField(auto_now=True) 以便每个对象都存储其最后修改时间。然后,也许一种机制可以从一个数据库中转储数据并将其加载到另一个数据库中,以便只保留最近修改的对象。
我正在考虑的可能性是 django 的 dumpdata、django-extensions dumpscript、django-test-utils makefixture 或 django-fixture 魔术。有很多事情要考虑,所以我不确定要走哪条路。
django - 将方法导入添加到 shell_plus
在shell_plus
中,有没有办法像模型一样自动导入选定的辅助方法?
我经常打开 shell 输入:
我想将其替换为:
django-extensions - 如何使用 EncryptedCharfield
是否有任何文档或示例/教程如何让 EncryptedCharField 在 Django 模型中工作?
我花了很多时间在我的 django 项目中安装 django-extension + keyczar 等。没有文档如何安装它。
到目前为止是这样的:
pip install django-extensions
将“django_extensions”添加到 INSTALLED_APPS
点安装 python-keyczar
使用 EncryptedCharField 创建模型 + 添加字段
添加 ENCRYPTED_FIELD_KEYS_DIR = '../../../enc-keys'
下载 KeyczarTool-0.71g-090613.jar
运行以下命令: java -jar KeyczarTool-0.71g-090613.jar create --location=./enc-keys -- purpose=crypt --name="first key" --asymmetric=rsa
到目前为止一切顺利,但是当我运行服务器时,出现以下错误:
keyczar.errors.KeyNotFoundError:没有找到带有 hash_val 标识符的键。
我无法弄清楚我做错了什么。
python - 如何使用 kCacheGrind 打开 python 配置文件数据?
我在 mac 上使用 qcachegrind 检查配置文件数据时遇到问题。我正在使用 django-extensions 生成配置文件数据。我可以在代码中使用 cProfile 打开正常的配置文件日志pyprof2calltree
,但我无法打开从/manage.py runprofileserver --prof-path=profile_data --use-cprofile --kcachegrind
. 有没有人成功管理过这个?
python - South 似乎不喜欢 PostgreSQLUUIDField
我在将 django_extensions.db.fields.PostgreSQLUUIDField 与我的 Django 模型一起使用时遇到问题,因为每次运行 schemamigration 时,South 都会继续尝试强制该字段成为 CharField。
结果,我似乎被迫手动编辑迁移以删除:
并编辑以下冻结模型定义:
至:
我在这里遗漏了一些明显的东西吗?
python - 来自 django-extensions 的 UUIDField 在基于类的视图中不可用
我有一个使用几个 UUIDField 的 Web 应用程序。在 Admin UI、基于函数的视图和其他 Python 代码中,这些字段按预期工作。但是,当尝试在 CBV 的“字段”中列出它们时,我收到错误消息:
这里的主题字段是ct_id。但是另一个人也这样做。
来自models.py:
如上所述,它们在管理员列表中工作:
在基于函数的视图中为 DynaTree 创建 JSON:
但在 CBV 中,这会引发错误:
关于如何使这项工作的任何想法?我只想渲染它们以供显示,而不是用于编辑。
谢谢
python - How do I install django-extensions and its dependancies without ever using the internet?
I am looking to install django-extensions and its dependancies (particularly six) without ever hitting the internet. I have the tarballs for both django-extensions and six, so am able to install offline. However, I see in my logs that pip firsts tries to find six on pypi before checking locally. Instead, I want to force the installer to never check pypi.
Log output (this is before I downloaded the six tarball, so please ignore the local packages error)
Installed /usr/local/lib/python2.7/site-packages/django_extensions-1.2.5-py2.7.egg
Processing dependencies for django-extensions==1.2.5
Searching for six
Reading http://pypi.python.org/simple/six/
Download error: [Errno -3] Temporary failure in name resolution -- Some packages may not be found!
Couldn't find index page for 'six' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Download error: [Errno -3] Temporary failure in name resolution -- Some packages may not be found!
No local packages or download links found for six
django - ipython 使用我的配置文件,但通过 django_extensions & shell_plus,它没有
我的 ipython 配置文件没有被 django_extensions 的 shell_plus 加载。
我的 ipython 配置文件包含:
测试它:
作品。现在,测试通过 django_extensions 调用的 ipython:
这让我进入 ipython(突出显示作品,%run 作品等),但没有加载我的配置:
我怎样才能让它工作?
ipython-notebook - 通过 django_extensions 使用时设置 IPython Notebook 保存目录
我正在通过 django_extensions 使用 IPython Notebook:
这会将笔记本文件保存到当前文件夹(Django 项目文件夹)。如何更改.ipynb
文件的保存位置?
python - Django 扩展/werkzeug runserver_plus 在捕获错误时崩溃并退出 247
这个问题几周前才出现,我无法追踪或修复它。我总是使用runserver_plus
开发服务器,这样我就可以使用 werkzeug 调试器。但是,由于某种原因,现在每当出现异常时,都会runserver_plus
崩溃,而不是正确显示 werkzeug 调试页面。
首先,只加载页面的 HTML:
然后服务器本身崩溃:
我在 Mac OS X(最新版本)上。我无法追踪退出代码 247 的含义——它仅在我在 PyCharm 中运行时出现。如果我在 PyCharm 之外运行它,但不告诉我状态码,服务器也会崩溃。