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 django.db import models   # Remove this 
from model_field_meta import models, FieldMetaMixin

class MyModel(FieldMetaMixin, models.Model):  # Add FieldMetaMixin
    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.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

django_model_field_meta-0.4-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-model-field-meta-0.4.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for django-model-field-meta-0.4.tar.gz
Algorithm Hash digest
SHA256 63ea28eabe45988e2a9887bc970ae159f39d1ae4f7d038bb8ec77820b0b28900
MD5 c6728e1a2b8590b03674b5ffc6dc0820
BLAKE2b-256 52d966bc6ea86a8718329b16c3606dc1e63ce5412775b9fda87b58dd18763d06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_model_field_meta-0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for django_model_field_meta-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f752df81f8dd855ed5b1db71f71a35c9bd645f8b03e1e01326d0c9816b90db48
MD5 50a301f3930d82b2ae27811f310a6a04
BLAKE2b-256 a01c606b15c8c52bd0a46ee6a09748388d279f6f8baae717ff51a9d5f36b1778

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