A flexible quering JSONField and associated form field to store validated JSON in your model.
Project description
Django-JSONField2
===================
``django-json-field2`` is a flexible quering JSONField and associated form field
It is a compilation and adaptation of the following projects
* https://bitbucket.org/schinckel/django-jsonfield
* https://github.com/derek-schaefer/django-json-field
* https://github.com/bradjasper/django-jsonfield
* https://github.com/certae/django-softmachine/blob/master/src/protoLib/fields.py
* https://github.com/frol/django-quering-jsonfield
* http://cramer.io/2009/04/14/cleaning-up-with-json-and-sql/
* http://natebeacham.com/blog/nate-beacham/31/
Feature Description
-------------------
South support
Form field
Form widget
Model field
Python3 support
``django-jsonfield2`` is also compatible with South, Django 1.8 and Python 3.
Installation
------------
Install from PyPI:
``pip install django-jsonfield2``
Source:
-------
``git clone git://github.com/DarioGT/django-jsonfield2.git``
Configuration
-------------
Add ``jsonfield2`` to your ``PYTHONPATH`` and ``INSTALLED_APPS`` setting:
::
INSTALLED_APPS = (
...
'jsonfield2',
...
)
::
Usage
-----
::
from django.db import models
from jsonfield2 import JSONField, JSONAwareManager
class JsonModel(models.Model):
code = models.CharField( blank=False, null=False, max_length=20 )
status = models.CharField( blank=True, null=True, max_length=20 )
info = JSONField(default={})
objects = JSONAwareManager(json_fields = ['info'])
def __str__(self):
return self.code
Json Query
----------
::
...
obj = Person.objects.create(name = "Bill")
obj.info = {
'sex': 'male',
'address': {
'country', 'Canada',
}
}
obj.save()
Person.objects.filter(info__address__country = 'Canada')
>>> [Person: "Bill"]
Usage
-----
Now, it will validate the JSON on entry, and store it as a text in the database. When you instantiate/fetch the object, it will be turned back into a python list/dict/string.
jsonify templatetag
-------------------
This allows you to convert a python data structure into JSON within a template::
{% load jsonify %}
<script>
var foo = {{ bar|jsonify }};
</script>
Tests
----------
``python runtest.py``
Todo
----------
Allow order_by when json criteria are used
License
-------
``django-jsonfield2`` is licensed under the New BSD license.
===================
``django-json-field2`` is a flexible quering JSONField and associated form field
It is a compilation and adaptation of the following projects
* https://bitbucket.org/schinckel/django-jsonfield
* https://github.com/derek-schaefer/django-json-field
* https://github.com/bradjasper/django-jsonfield
* https://github.com/certae/django-softmachine/blob/master/src/protoLib/fields.py
* https://github.com/frol/django-quering-jsonfield
* http://cramer.io/2009/04/14/cleaning-up-with-json-and-sql/
* http://natebeacham.com/blog/nate-beacham/31/
Feature Description
-------------------
South support
Form field
Form widget
Model field
Python3 support
``django-jsonfield2`` is also compatible with South, Django 1.8 and Python 3.
Installation
------------
Install from PyPI:
``pip install django-jsonfield2``
Source:
-------
``git clone git://github.com/DarioGT/django-jsonfield2.git``
Configuration
-------------
Add ``jsonfield2`` to your ``PYTHONPATH`` and ``INSTALLED_APPS`` setting:
::
INSTALLED_APPS = (
...
'jsonfield2',
...
)
::
Usage
-----
::
from django.db import models
from jsonfield2 import JSONField, JSONAwareManager
class JsonModel(models.Model):
code = models.CharField( blank=False, null=False, max_length=20 )
status = models.CharField( blank=True, null=True, max_length=20 )
info = JSONField(default={})
objects = JSONAwareManager(json_fields = ['info'])
def __str__(self):
return self.code
Json Query
----------
::
...
obj = Person.objects.create(name = "Bill")
obj.info = {
'sex': 'male',
'address': {
'country', 'Canada',
}
}
obj.save()
Person.objects.filter(info__address__country = 'Canada')
>>> [Person: "Bill"]
Usage
-----
Now, it will validate the JSON on entry, and store it as a text in the database. When you instantiate/fetch the object, it will be turned back into a python list/dict/string.
jsonify templatetag
-------------------
This allows you to convert a python data structure into JSON within a template::
{% load jsonify %}
<script>
var foo = {{ bar|jsonify }};
</script>
Tests
----------
``python runtest.py``
Todo
----------
Allow order_by when json criteria are used
License
-------
``django-jsonfield2`` is licensed under the New BSD license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-jsonfield2-15.06.07.tar.gz
(11.1 kB
view hashes)
Built Distribution
Close
Hashes for django-jsonfield2-15.06.07.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c08e1af3afb25ab2e95af35c39f73c1e1e06b41c8fd57d9547471b07d0221529 |
|
MD5 | 268fe044ea30b7cd4f6a10b5087bf69a |
|
BLAKE2b-256 | 254390866f6a1e061ba84ed07329a0db02284d7357ebcb618798ce67fb142770 |
Close
Hashes for django_jsonfield2-15.06.07-py3.4.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | b08c86c34028497a0ca19f7ef3d09604646b1997a3f0478ce1b8f5cf7a561455 |
|
MD5 | 4d98da15f8d16cd8b18ad85ec81b238a |
|
BLAKE2b-256 | 54af56fca21b5017e87549270a7717b9874894075bf165cc8c99787275f6f927 |