Reorganize code a bit, add current directory to sys.path (#198)

* reorganize code a bit

* add current directory to sys.path

* remove PYTHONPATH mention from the docs

* linting
This commit is contained in:
Maxim Kurnikov
2019-10-05 19:44:29 +03:00
committed by GitHub
parent b939bc96b7
commit 717be5940f
11 changed files with 287 additions and 238 deletions
+3 -3
View File
@@ -99,10 +99,10 @@ class AddRelatedModelsId(ModelClassInitializer):
def run_with_model_cls(self, model_cls: Type[Model]) -> None:
for field in model_cls._meta.get_fields():
if isinstance(field, ForeignKey):
related_model_cls = self.django_context.fields_context.get_related_model_cls(field)
related_model_cls = self.django_context.get_field_related_model_cls(field)
rel_primary_key_field = self.django_context.get_primary_key_field(related_model_cls)
field_info = self.lookup_class_typeinfo_or_incomplete_defn_error(rel_primary_key_field.__class__)
is_nullable = self.django_context.fields_context.get_field_nullability(field, None)
is_nullable = self.django_context.get_field_nullability(field, None)
set_type, get_type = get_field_descriptor_types(field_info, is_nullable)
self.add_new_node_to_model_class(field.attname,
Instance(field_info, [set_type, get_type]))
@@ -162,7 +162,7 @@ class AddRelatedManagers(ModelClassInitializer):
# no reverse accessor
continue
related_model_cls = self.django_context.fields_context.get_related_model_cls(relation)
related_model_cls = self.django_context.get_field_related_model_cls(relation)
related_model_info = self.lookup_class_typeinfo_or_incomplete_defn_error(related_model_cls)
if isinstance(relation, OneToOneRel):