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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c7eea80de9439391c882c6b1eb0137d96ea16bc322372b16314224d24fe4c15 |
|
MD5 | 5a70819b69406173c7c283dec0c93ba7 |
|
BLAKE2b-256 | f9d36e760cc857b7d17efa9b730beb81e3b6c30d7e73cbc07d5b047fa2059f48 |
Hashes for django_model_field_meta-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01dd0e7680aa950bd8f1705c80aa9c62ac7dd534723eb3ba9cba98b3c4a2b899 |
|
MD5 | d96462cb085018fa6c01e0a8c35f218b |
|
BLAKE2b-256 | 54bde9e7077cd219e5ab40152faf77418fd930329906938b0494208a2634a374 |