sbdchd / django-types

:doughnut: Type stubs for Django
MIT License
188 stars 62 forks source link

Support dynamic model instance attributes #125

Open knyghty opened 2 years ago

knyghty commented 2 years ago

Two I can think of offhand:

I'm making a bit of an assumption that this is possible - I don't really know.

ricky-sb commented 1 year ago

@sbdchd just curious, what would it take to enable this?

Essentially, making it so we don't have to manually define id: int on all our models? We'd have to read the related_name somehow and inform the type system beforehand, right?

sbdchd commented 1 year ago

Not really sure how to do it without some codegen aspect

problem is really lack of advanced stuff in python typing and how Django sets this stuff up

syastrov commented 1 year ago

I tried to solve something like this using codegen. See https://github.com/sbdchd/django-types/issues/158 if you are interested. Note that I'm not currently working on this -- just putting out what I created for those who are interested.