升级后Django-Picklefield变化结构
我将Django应用程序从1.11.16迁移到4.0.5,而Django-Picklefield也将从2.0迁移到3.1。
Django对象具有以下行:
from picklefield.fields import PickledObjectField
class A(models.Model):
...
log_list = PickledObjectField(default=list)
。
使用旧代码(1.11.16)和新代码(4.0.5)结果的查询结果完全不同:
#old
Obj.objects.get(id=4737).log_list
[{u'date': datetime.datetime(2022, 6, 27, 12, 54, 50, 746392),
u'message': u'Fetching trademark search started',
u'typ': u'info'},
{u'date': datetime.datetime(2022, 6, 27, 12, 54, 53, 423384),
u'message': u'Fetching trademark search finished',
u'typ': u'info'}]
#type == list
#new
Obj.objects.get(id=4737).log_list
gAJdcQEofXECKFgEAAAAZGF0ZXEDY2RhdGV0aW1lCmRhdGV0aW1....
#so it results exactly what is stored in the db.
#type == str
使用Picklefield版本3.1,我需要做 /更改其他任何事情以比使用版本== 2.0? 我该如何处理新设置以获取列表而不是STR?
I'm migrating a Django app from 1.11.16 to 4.0.5 and django-picklefield will be migrated also from 2.0 to 3.1 .
A django object has the following line:
from picklefield.fields import PickledObjectField
class A(models.Model):
...
log_list = PickledObjectField(default=list)
.
Using the old code (1.11.16) and the new code (4.0.5) results a totally different result for the query:
#old
Obj.objects.get(id=4737).log_list
[{u'date': datetime.datetime(2022, 6, 27, 12, 54, 50, 746392),
u'message': u'Fetching trademark search started',
u'typ': u'info'},
{u'date': datetime.datetime(2022, 6, 27, 12, 54, 53, 423384),
u'message': u'Fetching trademark search finished',
u'typ': u'info'}]
#type == list
#new
Obj.objects.get(id=4737).log_list
gAJdcQEofXECKFgEAAAAZGF0ZXEDY2RhdGV0aW1lCmRhdGV0aW1....
#so it results exactly what is stored in the db.
#type == str
With picklefield version 3.1 is there anything else I need to do / change to have the behaviour than with version == 2.0 ?
What should I do with the new setup to get the list instead of the str?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论