django-types
django-types copied to clipboard
ManyToManyField[Unknown, Unknown]
VSCode is saying my models.ManyToManyField(MyModel, blank=True)
is ManyToManyField[Unknown, Unknown]
. I'm wondering if that's because I don't have a through
model specified? Is there any way to make this work correctly without hand-generating a through model? My ForeignKeys are working fine.
Hmm we might need to tweak the overloads a bit, I think it should be possible to have it typed properly without having to specify the through model
This is a workaround, a bit nasty because the mock line shadows the actual line, that, regarding my editor at least, is considered as unreachable:
if TYPE_CHECKING:
from django.db.models.manager import ManyToManyRelatedManager
model1 = ManyToManyRelatedManager[Model1, 'Model2']()
else:
model1 = models.ManyToManyField(Model1, blank=True)