Django Rest Framework tools for django-hstore.
Tribute to Nodeshot
This code was originally written for Nodeshot and then extracted into this generic python package.
DRF-hstore version | DRF version | django-hstore version | Django version | Python version |
1.3 | 3.1.x | 1.3.1 to 1.4.0 | 1.6, 1.7, 1.8 | 2.7, 3.4 |
1.2 | 3.1.x | 1.3.1 to 1.4.0 | 1.6, 1.7, 1.8 | 2.7, 3.4 |
1.1 | 2.4.x | 1.3.1 to 1.3.5 | 1.6, 1.7 | 2.7, 3.4 |
1.0 | 2.4.x | 1.3.1 to 1.3.5 | 1.6, 1.7 | 2.7, 3.4 |
pip install djangorestframework-hstore
This field is not sufficient to support django-hstore schema-mode
.
from rest_framework import serializers
from myapp.models import MyModel
# rest_framework_hstore
from rest_framework_hstore.fields import HStoreField
class MyHStoreSerializer(serializers.ModelSerializer):
data = HStoreField()
class Meta:
model = MyModel
Supports django-hstore DictionaryField
and schema-mode
out of the box.
Prefer this to HStoreField
.
from myapp.models import MyModel
# rest_framework_hstore
from rest_framework_hstore.serializers import HStoreSerializer
class MyHStoreSerializer(HStoreSerializer):
class Meta:
model = MyModel
- Join the Django REST Framework HStore Mailing List and announce your intentions
- Follow the PEP8 Style Guide for Python Code
- Fork this repo
- Write code
- Write tests for your code
- Ensure all tests pass
- Ensure test coverage is not under 90%
- Document your changes
- Send pull request
Copyright (C) 2014 Federico Capoano
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.