Last active
September 24, 2016 22:27
-
-
Save kbussell/9fb26c9580d2b50778113b81ecfd93e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: j = JsonModel.objects.create(data={'some': 'data'}) | |
In [2]: j.id | |
Out[2]: 1 | |
In [3]: repr(j.data) | |
Out[3]: "{'some': 'data'}" | |
In [4]: j.save() | |
In [5]: j = JsonModel.objects.get(id=1) | |
In [6]: repr(j.data) | |
Out[6]: '\'{"some": "data"}\'' | |
In [7]: j.save() | |
In [8]: j = JsonModel.objects.get(id=1) | |
In [9]: repr(j.data) | |
Out[9]: '\'"{\\\\"some\\\\": \\\\"data\\\\"}"\'' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.postgres.fields import JSONField | |
from django.db import models | |
class JsonModel(models.Model): | |
data = JSONField() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment