Skip to main content

Django model field metadata and utilities

Project description

django-model-field-meta

An easy-to-use plugin to allow optional metadata of model fields.

Compatible with django-model-utils, safedelete, etc.

Tested on Python 3+, Django 2.1+.

Example

Inserting metadata:

from model_field_meta import models, FieldMetaMixin

class MyModel(FieldMetaMixin, models.Model):
    my_field = models.TextField(meta={"key": "value"})

Accessing metadata:

model_obj = MyModel.objects.first()

model_obj.get_field_meta("my_field")
# {"key": "value"}

Or,

MyModel.get_field_meta("my_field")
# {"key": "value"}

Installation

Install from PiPy:

pip install django-model-field-meta

or, if you are using Pipenv:

pipenv install django-model-field-meta

Why metadata in model field?

In one of my Django projects, I needed to supply extra information about our model fields.

For my purpose, help_text is too limited. Using code comments is not feasible as I need to use those information programatically.

Hence, django_model_field_meta package is created.

Compatibility with third-party packages

In my project, I use:

  • django-model-utils for its InheritanceManager.
  • safedelete for its SafeDeleteModel

So far, I haven't encounter any issue. Feel free to report if you do.

Issues

If you have questions or issues using it, please create a Github issue at:

https://github.com/melvinkcx/django-model-field-meta/issues

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

django-model-field-meta-0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

django_model_field_meta-0.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file django-model-field-meta-0.2.tar.gz.

File metadata

  • Download URL: django-model-field-meta-0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for django-model-field-meta-0.2.tar.gz
Algorithm Hash digest
SHA256 cef8c8ce1c0361dc989b3f675c5f2736e0aa5c132d5b744164fac8f1b4b1b080
MD5 692f35f9fe0fa22de156cc24a2b48942
BLAKE2b-256 9a048359bf67ee10d3ed50aff835674e729e7290dcf3ed722011153fa6672253

See more details on using hashes here.

File details

Details for the file django_model_field_meta-0.2-py3-none-any.whl.

File metadata

  • Download URL: django_model_field_meta-0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for django_model_field_meta-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2358176054e7391b1d1fc0f22591e37df6a6fc7231ac670410e885bfec2015f9
MD5 eaec190f31e565904c350790d3470701
BLAKE2b-256 a73433293af726058629c54e43c6791d0133a72fa68fbb7430c8b7c47e3e14f4

See more details on using hashes here.

Supported by

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