Fix crash if model from same app referenced in RelatedField cannot be resolved (#199)

* do not crash if model from same app refd in ForeignKey cannot be resolved

* bump to 1.2.0
This commit is contained in:
Maxim Kurnikov
2019-10-05 20:00:51 +03:00
committed by GitHub
parent 717be5940f
commit db9ff6aaf6
7 changed files with 69 additions and 11 deletions

View File

@@ -49,6 +49,8 @@ def get_field_type_from_lookup(ctx: MethodContext, django_context: DjangoContext
if isinstance(lookup_field, RelatedField) and lookup_field.column == lookup:
related_model_cls = django_context.get_field_related_model_cls(lookup_field)
if related_model_cls is None:
return AnyType(TypeOfAny.from_error)
lookup_field = django_context.get_primary_key_field(related_model_cls)
field_get_type = django_context.get_field_get_type(helpers.get_typechecker_api(ctx),