# Buggy code
def get_field_get_type(
    self, api: TypeChecker, field: Field, *, method: str
) -> MypyType:
    """Get a type of __get__ for this specific Django field."""
    field_info = helpers.lookup_class_typeinfo(api, field.__class__)
    if field_info is None:
        return AnyType(TypeOfAny.unannotated)

    is_nullable = self.get_field_nullability(field, method)
    if isinstance(field, RelatedField):
        related_model_cls = self.get_field_related_model_cls(field)

        if method == "values":
            primary_key_field = self.get_primary_key_field(related_model_cls)
            return self.get_field_get_type(api, primary_key_field, method=method)

        model_info = helpers.lookup_class_typeinfo(api, related_model_cls)
        if model_info is None:
            return AnyType(TypeOfAny.unannotated)

        return Instance(model_info, [])
    else:
        return helpers.get_private_descriptor_type(
            field_info, "_pyi_private_get_type", is_nullable=is_nullable
        )


# Traceback (AttributeError)
Traceback (most recent call last):
File "/usr/local/bin/mypy", line 10, in <module>
sys.exit(console_entry())
File "/usr/local/lib/python3.6/site-packages/mypy/__main__.py", line 8, in console_entry
main(None, sys.stdout, sys.stderr)
File "/usr/local/lib/python3.6/site-packages/mypy/main.py", line 83, in main
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/usr/local/lib/python3.6/site-packages/mypy/build.py", line 164, in build
result = _build(sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr)
File "/usr/local/lib/python3.6/site-packages/mypy/build.py", line 224, in _build
graph = dispatch(sources, manager, stdout)
File "/usr/local/lib/python3.6/site-packages/mypy/build.py", line 2526, in dispatch
graph = load_graph(sources, manager)
File "/usr/local/lib/python3.6/site-packages/mypy/build.py", line 2748, in load_graph
caller_state=st, caller_line=st.dep_line_map.get(dep, 1))
File "/usr/local/lib/python3.6/site-packages/mypy/build.py", line 1772, in __init__
self.compute_dependencies()
File "/usr/local/lib/python3.6/site-packages/mypy/build.py", line 2059, in compute_dependencies
self.manager.plugin.get_additional_deps(self.tree))
File "/usr/local/lib/python3.6/site-packages/mypy/plugin.py", line 743, in get_additional_deps
deps.extend(plugin.get_additional_deps(file))
File "/usr/local/lib/python3.6/site-packages/mypy_django_plugin/main.py", line 152, in get_additional_deps
related_model_module = related_model_cls.__module__
AttributeError: 'NoneType' object has no attribute '__module__'

# Fixed code
def get_field_get_type(
    self, api: TypeChecker, field: Field, *, method: str
) -> MypyType:
    """Get a type of __get__ for this specific Django field."""
    field_info = helpers.lookup_class_typeinfo(api, field.__class__)
    if field_info is None:
        return AnyType(TypeOfAny.unannotated)

    is_nullable = self.get_field_nullability(field, method)
    if isinstance(field, RelatedField):
        related_model_cls = self.get_field_related_model_cls(field)
        if related_model_cls is None:
            return AnyType(TypeOfAny.from_error)

        if method == "values":
            primary_key_field = self.get_primary_key_field(related_model_cls)
            return self.get_field_get_type(api, primary_key_field, method=method)

        model_info = helpers.lookup_class_typeinfo(api, related_model_cls)
        if model_info is None:
            return AnyType(TypeOfAny.unannotated)

        return Instance(model_info, [])
    else:
        return helpers.get_private_descriptor_type(
            field_info, "_pyi_private_get_type", is_nullable=is_nullable
        )