add annotations at django models fields
Project description
when model definition
import django_modelhint 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_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
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
File details
Details for the file django-modelhint-0.1.1.1.tar.gz
.
File metadata
- Download URL: django-modelhint-0.1.1.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0681b9c9e80914736e4e8f8db63d79f1c5f9224de904abe9ae6502bb6ed90dd6 |
|
MD5 | 8a16e17d200dbdfed3f8c72a8564a23a |
|
BLAKE2b-256 | e7382e2f43180dbd45a2c34c7747ae710eba09ed2e921d86c5bbbf9e2be8799d |