use postgres json field
This commit is contained in:
parent
bbaaeb7263
commit
1bac062a50
24 changed files with 284 additions and 45 deletions
22
pandora/entity/migrations/0005_jsonfield.py
Normal file
22
pandora/entity/migrations/0005_jsonfield.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2018-06-19 17:23
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entity', '0004_related_name_Document_documentproperties'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
'ALTER TABLE "entity_entity" ALTER COLUMN "data" TYPE jsonb USING "data"::text::jsonb'
|
||||
),
|
||||
migrations.RunSQL(
|
||||
'ALTER TABLE "entity_documentproperties" ALTER COLUMN "data" TYPE jsonb USING "data"::text::jsonb'
|
||||
),
|
||||
]
|
||||
|
|
@ -14,6 +14,7 @@ from django.contrib.auth.models import User
|
|||
from django.db.models.signals import pre_delete, post_init
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from oxdjango.fields import JSONField
|
||||
|
||||
import ox
|
||||
from oxdjango import fields
|
||||
|
|
@ -40,7 +41,7 @@ class Entity(models.Model):
|
|||
name = models.CharField(max_length=255)
|
||||
alternativeNames = fields.TupleField(default=())
|
||||
|
||||
data = fields.DictField(default={}, editable=False)
|
||||
data = JSONField(default=dict, editable=False)
|
||||
matches = models.IntegerField(default=0)
|
||||
|
||||
objects = managers.EntityManager()
|
||||
|
|
@ -271,7 +272,7 @@ class DocumentProperties(models.Model):
|
|||
document = models.ForeignKey(Document, related_name='documentproperties')
|
||||
entity = models.ForeignKey(Entity, related_name='documentproperties')
|
||||
index = models.IntegerField(default=0)
|
||||
data = fields.DictField(default={})
|
||||
data = JSONField(default=dict, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
return u"%r-%r" % (self.document, self.entity)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue