add annotations at django models fields
Project description
when model definition
import django_annoation as d
d.get_default_mapping().add_reserved_words(doc="")
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_annotation 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-modelhint-0.1.1.tar.gz
(3.6 kB
view hashes)