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.

Files for django-model-field-meta, version 0.5
Filename, size File type Python version Upload date Hashes
Filename, size django_model_field_meta-0.5-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-model-field-meta-0.5.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page