Saravanan666/pypi-org huggingface dataset:
Package: django-jsonfield-schema
Expose Django JSONField data as virtual model fieldsUse ModelForm and ModelAdmin as usual. Perform simple queries. Migrate to real
table columns when needed without code change.Suitable to store dumb business data, quick prototypes without DB migrations,
and replace multi-table inheritance joins.Use with caution! Replacing relational structures with JSON data should be
mindfull architecture decision.Works with any JSONFielddjango.contrib.postgres,django-annoying,django-mysql,
upcoming djangoCross-db JSONFieldWork in progresspart ofhttps://json-schema.orgdefinitions are only supported.Quick startfromdjangoimportformsfromdjango.contribimportadminfromdjango.dbimportmodelsfromjsonfield_schemaimportJSONSchemaclassEmployeeSchema(JSONSchema):full_name={"type":"string"}hire_date={"type":"string","format":"date"}salary={"type":"number","multiplyOf":0.01,}classEmployee(models.Model):_schema=EmployeeSchema()data=JSONField(default={})classEmployeeForm(forms.ModelForm):classMeta:model=Employeefields=['full_name','hire_date','salary']@admin.register(Employee)classEmployeeAdmin(admin.ModelAdmin):list_display=['full_name','hire_date']fields=['full_name',('hire_date','salary')]DemoThe demo shows how to handle multiple User types within single table with
JSONField andDjango-Polymodelsproxies.$exportDATABASE_URL=postgresql://viewflow:viewflow@localhost/viewflow$exportDJANGO_SETTINGS_MODULE=demo.settings$toxpythonmanage.pymigrate$toxpythonmanage.pyrunserverLicenseDjango JSONField-Schema is an Open Source project licensed under the terms of
the AGPL license -The GNU Affero General Public License v3.0with the Additional Permissions
described inLICENSE_EXCEPTIONYou can more read about AGPL atAGPL FAQThis package license scheme follows to GCC Runtime library licensing. If you use
Linux already, probably this package license, should not bring anything new to
your stack.Latest changelog0.3.0 2019-11-01Support for date/time/datetime valuesSupport for help_text (description) and verbose_name (verboseName) field specs
Package: django-json-field-schema-validator
django-json-field-schema-validatorTiny tool for Django JSONField validation throughJSON SchemaInstallationpipinstalldjango-json-field-schema-validatorExamplefromdjango.dbimportmodelsfromdjango_json_field_schema_validator.validatorsimportJSONFieldSchemaValidatorschema={'$schema':f'http://json-schema.org/draft-07/schema#','type':'object','properties':{'foo':{'type':'number'},'bar':{'type':'string'}},'required':['foo','bar']}classSomeModel(models.Model):some_field=models.JSONField(validators=[JSONFieldSchemaValidator(schema)])
Package: django-jsonfilter
Django’s dumpdata management command allows you to dump objects from a given
application, but sometimes you’ll want to extract all objects of a givenmodelfrom a much larger file containing objects from many models.This package provides the jsonfilter.py commandline utility, which will
allow you to do just that.Ultimately the idea would be to also add options to be able to search on
different model fields to extract the objects you want before importing
them again into the database.Although it loads the entire json in memory, it’s actually quite fast. On a
41.6MB json file containing 131515 objects, it takes about 3s to extract
10341 objects of a given type. The 3s is actually fairly constant, however
many objects there are of the model it’s extracting.Seejsonfilter.py--helpfor usage.You can install this package through easy_install and pip.© Copyright 2010 Éric St-Jean, email: esj a-t w w d d-o-t c aThis file is part of django-jsonfilter.django-jsonfilter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.django-jsonfilter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with django-jsonfilter.  If not, see <http://www.gnu.org/licenses/>.
Package: django-jsonform
A user-friendly JSON editing form for django admin.Documentation•Playground•PyPIFeaturesFile uploadsPostgresArrayFieldMany inputs and field typesUI matches with Django admin'sRecursion (nesting with self references)ValidationScreenshotsHere's a screenshot of items being added to a shopping list (JSON array) dynamically:InstallInstall via pip:$pipinstalldjango-jsonformEdit yoursettings.pyfile:# settings.pyINSTALLED_APPS=[# ...'django_jsonform']Upgrading notesWhen upgrading from an older version of this library, please ensure that your
browser is loading the latest static JavaScript files that come with this library.In the development environment, clear the browser cache.In the production environment, you must run thecollectstaticcommand to update
the static files.DocumentationQuickstart and usage docs can be found athttp://django-jsonform.rtfd.io.ContributingThe JavaScript code is written in React and it lives in another repo:https://github.com/bhch/react-json-form.The JS code lacks proper documentation or comments, so before contributing, maybe open an issue and I can help you out.For everything else (related to Django or widget's css), contribute directly to this repo.LicenseBSD-3-Clause
Package: django-jsonforms
django-jsonforms provides a Django integration of json-editor (https://github.com/json-editor/json-editor).
A form field is provided that renders the dynamic form created by json-editor, loading in the provided schema and options along with any initial form data.
The field can be rendered in the same way as any other django field and also validates submitted data against your json schema on submission.InstallationInstall with pippip installdjango-jsonformsAdddjango_jsonformsto your INSTALLED_APPSMake sure you have APP_DIRS set to True in yourTEMPLATESsetting.
More about the templates setting here:https://docs.djangoproject.com/en/2.0/ref/settings/#templatesRequirementsjQueryis required on the page that will be rendering the form.UsageThe field can be used like any other Django form field, it has the schema and options attributes which can be either python dictionaries or paths to static files as as shown belowThe schema parameter is the json schema the field will useThe options parameter is passed through to the json-editor object, these options are described here:https://github.com/jdorn/json-editor#options(the schema option is not used)An optional ajax parameter determines whether any files are loaded via ajax on the frontend or loaded in the backend and put into html parameters (defaults to true)Example:from django.forms import ModelForm, Form
from django_jsonforms.forms import JSONSchemaField

class RegistrySettingsForm(Form):

    json = JSONSchemaField(
        schema = 'schema/schema.json',
        options = 'schema/options.json'
    )In this example the schema file would be located in ‘static/schema/schema.json’. You will need to run collectstatic after creating the fileTo load the file from a directory other than STATIC_ROOT see theJSONFORMS_SCHEMA_DIRsetting belowExample showing all options:class RegistrySettingsForm(Form):

    json = JSONSchemaField(
        schema = 'schema/schema.json',
        options = {"theme": "bootstrap3"},
        ajax = false
    )Since it is common to have only one field in this type of form. A form with a single JSONSchemaField named json is also available to useForm Example:from django_jsonforms.forms import JSONSchemaForm

form = JSONSchemaForm(schema=... , options=... , ajax=...)Note:When rendering the form don’t forget to render the forms media with the template tag {{ form.media }}. This is required for the field to function correctlyThe data returned when the field is submitted is in the form of a python dictionary. This may need to be converted before being stored depending on the model field being usedSettingsTheJSONFORMS_SCHEMA_DIRsetting can be used to specify the file directory to load the schema from. This directory will need to be seving static files for the form to funciton correctlyTheJSONFORMS_SCHEMA_VALIDATEsettings can be set to False to disable backend validation of the submitted json. This can allow a user to submit any json if the frontend validation is bypassed. This settings should only be used during development
Package: django-jsonify
AbstractJSON library for working with django + jsonDonorsjsonify filter for Django based onhttp://djangosnippets.org/snippets/201/@ajax_request decorator from django-annoyinghttps://bitbucket.org/offline/django-annoying(Anderson <self.anderson@gmail.com>)InstallationTo install you can use pip:pip install django-jsonifyThen addjsonifyto django settings.INSTALLED_APPSUsageIf you want to convert varianble in django template, you can use jsonify filter:{% load jsonify %}

{% block content %} <script type="text/javascript">
    <![CDATA[ var items = {{ items|jsonify }}; ]]></script>
{% endblock %}If you want to return JSON data from view, you can use @ajax_request decoratorfrom jsonify.decorators import ajax_request

@ajax_request
def my_view(request):
    news = News.objects.all()
    news_titles = [entry.title for entry in news]
    return {'news_titles': news_titles}
Package: django-jsonis
Helper library that can be used in combination with Django Class-Based views to return JSON responses.Warning: this is a work in progress, pending code refactoring and documentationFeaturesJSONApiResponseMixin providing render_api_response and render_api_error_response methodsAccept JSON request payloadJSONApiFormView that can be used for simple JSON APIs using django.formsJSON Web token validation (custom django middleware&auth backend)JSONTestClient providing utilities that can be used to test created APIsDefault JSONEncoder handling Decimal numbersSimple jsonify template filter (add ‘jsonis’ to your application list in settings)LicenseThis software is licensed under MIT.TODOExamples!DocumentationCode CleanupTests
Package: django-jsonlistedit
I’ve never written a django widget or field type, or anything custom like that
before, so I’m pretty much working this out as I go.This is the django component to get my JSONListEdit JS/HTML widget thing into
django (forms/admin).https://github.com/danthedeckie/json_listedit_widgetI suspect this component will never be ‘drop into django and it works!’ as there
are too many variables you need to configure to get anything useful.However, there is / will be a more useable-out-of-the-box component
(https://github.com/danthedeckie/django_jsonlisttable) which is based on this.
Package: django-json-logger
DescriptionThis library provides the ability of converting django logs to JSON.InstallationUsing standard Json library:pipinstallgit+https://github.com/missterr/django-json-logging.gitCustom json librariesOrjsonTo useOrjson:pipinstallgit+https://github.com/missterr/django-json-logging.git#egg=django-json-logging[orjson]and add to Django settingsLOGGING_SERIALIZER="orjson"UjsonTo useUjson:pipinstallgit+https://github.com/missterr/django-json-logging.git#egg=django-json-logging[ujson]and add to Django settingsLOGGING_SERIALIZER="ujson"Note:  If you're using zsh you need to escape square brackets: pip install ... [ujson]UsageDjango setup# setting.pyLOGGING_APP_NAME='your_app_name'# requiredLOGGING_FIELDS=('levelname','name','module','process','thread','pathname','asctime')LOGGING={'version':1,'disable_existing_loggers':False,'formatters':{'json':{'()':'django_json_logging.formatters.JSONFormatter',},},'handlers':{'console':{'class':'logging.StreamHandler','formatter':'json',},},'loggers':{'':{'handlers':['console'],'level':'WARNING',},'django':{'handlers':['console'],'level':'WARNING','propagate':False,},},}Somewhere in the codeimportloggingyour_json_logger=logging.getLogger('json_logger')your_json_logger.warning('Something happened here',extra={'event_code':'xxx'})Exhaustive fields list can be found here
Package: django_json_logging
django_json_loggingVarious JSON logging extensions for the Django FrameworkInstallationUsing pippip install django_json_loggingUsing pipenvpipenv install django_json_loggingQuick startIn your project’ssettings.pyaddAccessLogMiddlewaretoMIDDLEWAREand addJSONFormattertoLOGGING.MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ...
    'django_json_logging.middleware.AccessLogMiddleware',
]LOGGING = {
    ...
    'formatters': {"json": {'()': 'django_json_logging.logging.JSONFormatter'}},
    ...
}
Package: django-json-messages
# django-json-messagesAdd json encoded messages (from Django messages framework) to templates# Install```shpip install django-json-messages```# Usage## Django messagesMake sure the [Django messages framework](https://docs.djangoproject.com/en/1.7/ref/contrib/messages/) is installed and working.## AppAdd `json_messages` to your list of `INSTALLED_APPS`## Context processorAdd `json_messages.context_processors.json_messages` in your `CONTEXT_PROCESSORS` settings.A `json_messages` property is now available on the context.It is a dict version of the messages with `msg` and `type` keys## Template tags### LoadingUse `{% load json_messages %}` at the top of your template### Json dumpUse `{% json_messages_dump %}` to simply dump the json encoded messages into your template**Note** that all messages' `msg` properties are passed through Django's [escapejs](https://docs.djangoproject.com/en/dev/ref/templates/builtins/#escapejs) for security reasons.### ScriptUse `{% json_messages_script %}` to dump the messages array into a Javascript window variable called ` messages `This is equivalent to writing```<script type="text/javascript">window.messages = {% json_messages_dump %};</script>```#### Configuration- Set a context variable `js_variable` to override the name of the window variable use by `{% json_messages_script %}`*Example:*```{% json_messages_script js_variable="blop" %}```results in```<script type="text/javascript">window.blop = [{"type":"danger", "msg":"Something"}];</script>```Defaults to *"messages"*## Package dependenciesNone
Package: django-json-model-widget
django-json-model-widgetDjango widget for storing model instances pairs in flat JsonField.Install stable version from PyPIInstall from PyPI:pip install django-flat-json-widgetUsageAdd flat_json_widget to INSTALLED_APPS:INSTALLED_APPS=[# other apps...'json_model_widget',]Then load the widget where you need it, for example, here's how to use it in the django admin site:fromdjangoimportformsfromjson_model_widget.widgetsimportJsonPairInputsfrom.modelsimportmodel1,model2classMyForm(forms.ModelForm):classMeta:widgets={'fieldname':JsonPairInputs(model1,model2)}ContributorsOleg Galichkingalij899@yandex.ruHistory
Package: django_jsonp
Simple JSONP support for djangoInstallationInstall usingpip…$pipinstalldjango-jsonpUsagefromdjsonpimportjsonp,JSONPResponse,get_callback# decorate something that returns a dict-like object@jsonpdefmy_view(request):return{'foo':'bar'}# it can work with an HttpResponse instances@jsonpdefanother_view(request):returnHttpResponse("{'foo': 'bar'}")# or just return a JSONPResponsedefjsonp_view(request):returnJSONPResponse(data={'foo':'bar',},callback=get_callback(request))# it also works for CBVsfromdjango.views.genericimportView@jsonpclassDictResponse(View):defget(self,request):returnHttpResponse("{'foo': 'bar'}")
Package: django-json-patch
JSON Patchsupport for Django models.DocumentationThe full documentation is athttps://django-json-patch.readthedocs.io.InstallInstall django-json-patch:pip install django-json-patchUsagefrom json_patch.patch import Patch
from models import Author

authors = Author.objects.all()

add_author = [
    {
        'op': 'add',
        'path': '/0',
        'value': {
            'id': 1,
            'name': 'Bob'
        }
    }
]

patch = Patch(add_author_diff)
patch.apply(authors)History0.1.0 (2015-10-02)First release on PyPI.
Package: django-jsonplus
Django extension for non-basic types’ serialization to JSON viajsonpluslib.InstallInstall from PyPI:pip install django-jsonplusAdd to yoursettings.py:INSTALLED_APPS=[<other-apps>'django_jsonplus',]UsageTo usejsonplusfor database values (de-)serialization, use theJSONPlusField:fromdjango.dbimportmodelsfromdjango.contrib.postgres.fieldsimportJSONFieldfromdjango_jsonplus.modelsimportJSONPlusFieldclassMyModel(models.Model):# stores only numbers, strings, lists, dicts (but not dates)basic_data=JSONField()# stores datetime, namedtuple, set, decimal, complex...rich_data=JSONPlusField()
Package: django-json-renderer
A Simple json renderer for django.Installpip install django-json-rendererApiJsonResponseNative DjangoJsonResponse(or it’s polyfill).ModelJSONEncoderInherit fromDjangoJSONEncoder, extends the parser
ofQuerySet(usinglist(queryset.values())) andModels(usingmodel_to_dict).render_json(encoder=ModelJSONEncoder, safe=True, **kwargs)Return the
decorator that convert json-serializable to JsonResponse (usingModelJSONEncoderas default).encoderandsafeparams has the same
meaning asDjango JsonResponse.Examplefromdjango.dbimportmodelsfromdjango_json_encoderimportrender_jsonclassPerson(models.Model):first_name=models.CharField(max_length=30)last_name=models.CharField(max_length=30)@render_json()defget_first_person(request):returnPerson.objects.all().first()## `safe` params@render_json(safe=False)defget_all_person(request):returnPerson.objects.all()LicenseMIT
Package: django-jsonresponse
Wrap view functions, allowng them render python native and custom
objects to jsonUsageSimple wrap returning data into jsonfromjsonresponseimportto_json@to_json('plain')defhello(request):returndict(hello='world')GET /hello/
{"hello": "world"}Result can be wraped in some api manier. Note, you can pass debug=1 to
pretty print response. UseJSONRESPONSE_DEFAULT_DEBUG=Trueto enable
by default.@to_json('api')defgoodbye(request):returndict(good='bye')GET /goodbye/?debug=1
{
    "data": {
        "good": "bye"
    },
    "err": 0
}Automaticaly error handling, note response code is 500 here@to_json('api')deferror(request):raiseException('Wooot!??')GET /error/
{
    "err_class": "Exception",
    "err_desc": "Wooot!??",
    "data": null,
    "err": 1
}You can pass raise=1 to raise exceptions in debug purposes instead of
passing info to json responseGET /error/?raise=1
Traceback (most recent call last):
Exception: Wooot!??You can pass custom kwargs to json.dumps, just give them to constructor:@to_json('plain',separators=(',',':'))defcustom_kwargs(request):return['a',{'b':1}]GET /
["a",{"b":1}]You can serialize not only pure python data types. Implementserializemethod on toplevel object or each element of toplevel
array. Note, that request object is passed to serialize method.classUser(object):def__init__(self,name,age):self.name=nameself.age=agedefserialize(self,request):ifrequest.GET.get('with_age',False):returndict(name=self.name,age=self.age)else:returndict(name=self.name)@to_json('objects')defusers(request):return[User('Bob',10),User('Anna',12)]GET /users/?with_age=1
{
    "data": [
        {
            "age": 10,
            "name": "Bob"
        },
        {
            "age": 12,
            "name": "Anna"
        }
    ],
    "err": 0
}It is easy to use jsonp, just pass format=jsonpGET /users/?format=jsonp
callback({
    "data": [
        {
            "name": "Bob"
        },
        {
            "name": "Anna"
        }
    ],
    "err": 0
});You can override the name of callback method usingJSONRESPONSE_CALLBACK_NAMEoption or query arg
callback=another_callbackGET /users/?format=jsonp&callback=my_callback
my_callback({
    "data": [
        {
            "name": "Bob"
        },
        {
            "name": "Anna"
        }
    ],
    "err": 0
});
Package: django-json-response
django-json-responseJsonResponse is New in Django 1.7Ref:https://docs.djangoproject.com/en/1.8/ref/request-response/#jsonresponse-objectsInstallationpip install django-json-responseWarningSince Version 1.1.3, the JsonpResponse return Object replace of String.

"{}('{}')" ==> '{}({});'Usagefrom json_response import JsonResponse

def json_view(request):
    objs = SomeModel.objects.all()

    return JsonResponse({
        'status': 200,
        'message': u'成功',
        'data': {
            'data1': 'xxx',
            'data2': 'ooo',
            'objs': [obj.data for obj in objs]
        }
    })


or


from json_response import JsonpResponse

def jsonp_view(request):
    callback = request.GET.get('callback', '')

    objs = SomeModel.objects.all()

    return JsonpResponse(callback, {
        'status': 200,
        'message': u'成功',
        'data': {
            'data1': 'xxx',
            'data2': 'ooo',
            'objs': [obj.data for obj in objs]
        }
    })

or

from json_response import json_response, jsonp_response, auto_response

@json_response
def json_view(request):
    objs = SomeModel.objects.all()

    return {
        'status': 200,
        'message': u'成功',
        'data': {
            'data1': 'xxx',
            'data2': 'ooo',
            'objs': [obj.data for obj in objs]
        }
    }

@jsonp_response
def jsonp_view(request):
    objs = SomeModel.objects.all()

    return {
        'status': 200,
        'message': u'成功',
        'data': {
            'data1': 'xxx',
            'data2': 'ooo',
            'objs': [obj.data for obj in objs]
        }
    }

@auto_response
def jsonp_view(request):
    objs = SomeModel.objects.all()

    return {
        'status': 200,
        'message': u'成功',
        'data': {
            'data1': 'xxx',
            'data2': 'ooo',
            'objs': [obj.data for obj in objs]
        }
    }
Package: django-jsonschema
Introductiondjango-jsonschema converts Django Forms into JSON Schema compatibile representationsRequirementsPython 2.6 or laterDjango 1.4 or laterUsageTo convert a form to a JSON Schema:from djangojsonschema.jsonschema import DjangoFormToJSONSchema

schema_repr = DjangoFormToJSONSchema().convert_form(MyForm)To embed a JSON Schema as a form field:from djangojsonschema.forms import JSONSchemaField

#where schema is a python dictionay like schema_repr in the first exmaple

class MyForm(forms.Form):
    subfield = JSONSchemaField(schema=schema)

form = MyForm(data={'subfield':'<json encoded value>'})
form.validate() #will validate the subfield entry against schema
form['subfield'].as_widget() #will render a textarea widget with a data-schemajson attribute
Package: django_json_schema
django json schemaCreates json schema from django modelsFree software: MIT licenseDocumentation:https://django-json-schema.readthedocs.io.FeaturesTODOCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2016-07-13)First release on PyPI.
Package: django-json-schema-validator
Validator is a Django app used to validate request and response objects for django apis.Quick startAdd “validator” to your INSTALLED_APPS setting like this before your apps:INSTALLED_APPS = [
    ...
    'validator',
]Add “validator.middleware.Validator” to your MIDDLEWARE setting like this:MIDDLEWARE = [
    ...
    'validator.middleware.Validator',
    'django.middleware.common.CommonMiddleware',
    ...
]Add SCHEMA variable in settings.py, which gives the location of the schema.json file.SCHEMA = ‘ext_app/schema.json’Add DOCUMENTATION variable in settings.py, which gives the location of the DOC.md file to be generated.DOCUMENTATION = ‘ext_app/DOC.md’To generate api documentation from schema.json, runpython3 manage.py gen_docs