Skip to content

Commit

Permalink
Fix support for python<3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Offpics committed Jun 26, 2019
1 parent 1e96587 commit 75f523f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions django_extensions/management/modelviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,17 @@ def process_local_fields(self, field, model, abstract_fields):
# excluding fields inherited from abstract classes. they too show as local_fields
return newmodel
if isinstance(field, OneToOneField):
relation = self.add_relation(field, newmodel, '[arrowhead=none, arrowtail=none, dir=both]')
relation = self.add_relation(
field, newmodel, '[arrowhead=none, arrowtail=none, dir=both]'
)
elif isinstance(field, ForeignKey):
relation = self.add_relation(field, newmodel, f'[arrowhead=none, arrowtail={self.arrow_shape}, dir=both]')
relation = self.add_relation(
field,
newmodel,
'[arrowhead=none, arrowtail={}, dir=both]'.format(
self.arrow_shape
),
)
else:
relation = None
if relation is not None:
Expand All @@ -361,7 +369,13 @@ def process_local_many_to_many(self, field, model):
relation = None
if isinstance(field, ManyToManyField):
if hasattr(field.remote_field.through, '_meta') and field.remote_field.through._meta.auto_created:
relation = self.add_relation(field, newmodel, f'[arrowhead={self.arrow_shape} arrowtail={self.arrow_shape}, dir=both]')
relation = self.add_relation(
field,
newmodel,
'[arrowhead={} arrowtail={}, dir=both]'.format(
self.arrow_shape, self.arrow_shape
),
)
elif isinstance(field, GenericRelation):
relation = self.add_relation(field, newmodel, mark_safe('[style="dotted", arrowhead=normal, arrowtail=normal, dir=both]'))
if relation is not None:
Expand Down

0 comments on commit 75f523f

Please sign in to comment.