Skip to main content

add annotations at django models fields

Project description

when model definition

import django_modelhint as d

class Group(models.Model):
    name = d.CharField(max_length=255, verbose_name="Name", doc="名前")

class User(models.Model):
    group = d.ForeignKey(Group)
    name = d.CharField(max_length=255, verbose_name="Name", doc="名前")

when view

import django_modelhint as d
user = User.objects.get()
d.get_mapping(user)  # => ChainMap({}, {'name': ChainMap({}, {'doc': '名前'}), 'id': ChainMap({}, {'doc': ''}), 'group': ChainMap({}, {'doc': ''})})
d.get_mapping(user)["name"]["doc"]  # => '名前'

group = Group.objects.get()
d.get_mapping(group.user_set)  # => ChainMap({}, {'name': ChainMap({}, {'doc': '名前'}), 'id': ChainMap({}, {'doc': ''}), 'group': ChainMap({}, {'doc': ''})})

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-modelhint, version
Filename, size File type Python version Upload date Hashes
Filename, size django-modelhint- (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page