When using django-types, you need to add a lot of boilerplate in order to fill in the attributes that Django would normally add to your models.
I thought I would share an experiment with you that I made in this direction about a year ago, which will automatically generate this boilerplate using libcst's codemod feature.
Annotations for RelatedManagers for the reverse accessors for foreign keys
I don't have the time or interest to continue working on this, but if anyone would like to experiment with it, or fork it into something more production-ready, then feel free to do so.
When using
django-types
, you need to add a lot of boilerplate in order to fill in the attributes that Django would normally add to your models.I thought I would share an experiment with you that I made in this direction about a year ago, which will automatically generate this boilerplate using libcst's codemod feature.
A very rough proof-of-concept is available at: https://github.com/syastrov/django_type_gen/
Right now, it will add to your models:
id
annotation (it currently assumes it's anint
)pk
annotationFK_id
annotation for foreign keysRelatedManager
s for the reverse accessors for foreign keysI don't have the time or interest to continue working on this, but if anyone would like to experiment with it, or fork it into something more production-ready, then feel free to do so.