一个JSonb领域的模型转换
django-modeltrans的Python项目详细描述
django modeltrans
使用注册方法在JSONField
中转换django模型字段。
功能/要求
- 每个模型使用一个
django.contrib.postgres.JSONField
(postgresql jsonb字段)。 - django 1.11、2.0(及其支持的python版本)
- PostgreSQL=9.5和Psycopg2=2.5.4。
- Available on pypi
- Documentation
运行测试
tox
仅在当前环境下运行测试,使用make test
归因
一些概念和代码来自https://github.com/deschler/django-modeltranslation, 它的灵感来自https://github.com/zmathew/django-linguo
我们在Zostera启动此解决方案,因为我们不喜欢:
- Django ModelTranslation为每种语言添加一个字段的方式(因此需要迁移 添加语言时);
- 原始字段的不可预测性。
由于postgres现在支持JSONB
,我们开发了这种方法。