Best way to exclude "some" relations from graph

34 views
Skip to first unread message

Andi Albrecht

unread,
Mar 9, 2011, 4:42:18 AM3/9/11
to django-e...@googlegroups.com
Hi,

I have the following abstract base class 

class DefaultInfo(models.Model):
  created_by = models.ForeignKey(User)
  modified_by = models.FroreignKey(User)

  class Meta:
    abstract = True

and a bunch of models using this class as their base.

When creating a graph I want to exclude the ForeignKey fields from DefaultInfo, otherwise the graph becomes really unreadable due to the relations to the User object. Note that there are some models that add an extra relation to the User model, so completely ignoring the User model isn't an option.

To get a more readable graph I've made a trivial change in modelviz.py:

--- modelviz.py.orig 2011-03-09 10:36:51.297678887 +0100
+++ modelviz.py 2011-03-09 10:36:27.037643302 +0100
@@ -252,7 +252,7 @@
                     'arrows': extras,
                     'needs_node': True
                 }
-                if _rel not in model['relations'] and consider(_rel['target']):
+                if field not in abstract_fields and _rel not in model['relations'] and consider(_rel['target']):
                     model['relations'].append(_rel)
 
             for field in appmodel._meta.fields:

Disabling all relations defined in abstract fields sounds a bit rude. Is there a recommended way to ignore specific relations?

-Andi
Reply all
Reply to author
Forward
0 new messages