Skip to main content

A model JSONField with an integrated form for django.

Project description

A model JSONField with an integrated form for django.

Before doing this app we looked up for a JSONField implementation, but all that we have found had nothing that fit our needs. Our needs are just a model field to store a json string and a form that is able to validate user input against our json fields requirements.

Installation

Just copy this project to any folder in your computer or use pip.

pip install vlk-django-jsonfield

Usage

### Model

To create your JSONField just use the same notation as an usual model field:

jsonfield = VLKJSONField(null=True, default=lambda: {‘field1’: False, ‘field2’: ‘abc’})

[You must use lambda when using a dict as default] (https://docs.djangoproject.com/en/dev/ref/models/fields/#default)

### Form

To use this field in a form just use the form field with the same name of your model field and the subname separated by __:

jsonfield__field1 = forms.CharField() jsonfield__field2 = forms.IntegerField(required=False)

The right side is the usual of a form field.

Who is using

This project is used in Vialink software since January, 2013. Are you using it? Let us know :)

Contributing

Do the usual github fork and pull request dance.

Authors

License

Released under the MIT license. Read LICENSE.md for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vlk-django-jsonfield-1.1.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file vlk-django-jsonfield-1.1.tar.gz.

File metadata

File hashes

Hashes for vlk-django-jsonfield-1.1.tar.gz
Algorithm Hash digest
SHA256 5691bce7d47b1799148b96d697e4a755ef9df2dbf0299b54525e4d540ac54b39
MD5 2753d101abdb6d8f5e5743ce875afded
BLAKE2b-256 61a7a33db44693d20c88e012d3f647034ce8b0b5355d5d20fb22cd484aa7f54b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page