Changes between Version 9 and Version 10 of DjangoGraphviz
- Timestamp:
- Aug 6, 2006, 1:02:06 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DjangoGraphviz
v9 v10 31 31 $ python modelviz.py <app_label> > <filename>.dot 32 32 33 Example: 33 Changelog 34 34 35 $ python modelviz.py camera > foo.dot 35 0.4 36 Fixed OneToOneField support (thanks, limodou) 37 38 0.3 39 Added support for GenericRelation and OneToOneField 40 41 0.2 42 Changed display (shape="record", thanks Malcolm Tredinnick), 43 fixed arrow direction, added display of model attributes 44 (thanks, Russell Keith-Magee) 45 46 0.1 47 First release. 36 48 """ 49 50 __version__ = "0.4" 51 __license__ = "Python" 52 __author__ = "Antonio Cavedoni <http://cavedoni.com/" 53 __contributors__ = [ 54 "Stefano J. Attardi <http://attardi.org/>", 55 "limodou <http://www.donews.net/limodou/>" 56 ] 37 57 38 58 from django.db import models … … 64 84 label = "{%s |""" % (o.__name__, o.__name__)) 65 85 66 # m embers86 # model attributes 67 87 for field in o._meta.fields: 68 88 nodes.append('%s : %s\\l' % (field.name, type(field).__name__)) … … 72 92 nodes.append('%s : %s\\l' % (field.name, type(field).__name__)) 73 93 74 if o._meta.one_to_one_field:75 for field in o._meta.one_to_one_field:76 nodes.append('%s : %s\\l' % (field.name, type(field).__name__))77 78 94 nodes.append(""" }"\n]\n""") 79 95 print "".join(nodes) … … 81 97 # relations 82 98 rel = [] 99 100 for field in o._meta.fields: 101 if isinstance(field, ForeignKey): 102 _rel = ' %s -> %s [label="%s"];' % \ 103 (o.__name__, field.rel.to.__name__, type(field).__name__) 104 if _rel not in rel: 105 rel.append(_rel) 106 elif isinstance(field, OneToOneField): 107 _rel = ' %s -> %s [label="%s"] [arrowhead=none arrowtail=none];' % (o.__name__, field.rel.to.__name__, type(field).__name__) 108 if _rel not in rel: 109 rel.append(_rel) 110 83 111 for field in o._meta.fields: 84 112 if isinstance(field, ForeignKey): … … 102 130 rel.append(_rel) 103 131 104 if o._meta.one_to_one_field:105 for field in o._meta.one_to_one_field:106 if isinstance(field, OneToOneField):107 _rel = ' %s -> %s [label="%s"] [arrowhead=none arrowtail=none];' % \108 (o.__name__, field.rel.to.__name__, type(field).__name__)109 if _rel not in rel:110 rel.append(_rel)111 112 132 print "\n".join(rel) 113 133