typelets.django.models¶
Typing useful for Django models.
Added in version 1.0.
Module Attributes
Type alias for a primary key. |
|
Type alias for an int-based primary key. |
- typelets.django.models.ModelAnyPK¶
Type alias for a primary key.
Django primary keys default to
Any, which doesn’t particularly help code stay readable.This type can be used instead to specifically document a type as being any compatible form of a model primary key.
Added in version 1.0.
Example
pk: ModelAnyPK = obj.pk
- typelets.django.models.ModelIntPK¶
Type alias for an int-based primary key.
Django primary keys default to
Any, which doesn’t particularly help code stay readable. And sometimes a codebase knows that it’s only going to be working with integer-based primary keys.This type can be used instead to specifically document an integer-based primary key for a model.
Added in version 1.0.
Example
pk: ModelIntPK = obj.pk