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 itsInheritanceManager
.safedelete
for itsSafeDeleteModel
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:
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
Built Distribution
Hashes for django-model-field-meta-0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ea28eabe45988e2a9887bc970ae159f39d1ae4f7d038bb8ec77820b0b28900 |
|
MD5 | c6728e1a2b8590b03674b5ffc6dc0820 |
|
BLAKE2b-256 | 52d966bc6ea86a8718329b16c3606dc1e63ce5412775b9fda87b58dd18763d06 |
Hashes for django_model_field_meta-0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f752df81f8dd855ed5b1db71f71a35c9bd645f8b03e1e01326d0c9816b90db48 |
|
MD5 | 50a301f3930d82b2ae27811f310a6a04 |
|
BLAKE2b-256 | a01c606b15c8c52bd0a46ee6a09748388d279f6f8baae717ff51a9d5f36b1778 |