Changes between Version 9 and Version 10 of DjangoGraphviz


Ignore:
Timestamp:
Aug 6, 2006, 1:02:06 PM (18 years ago)
Author:
Antonio Cavedoni
Comment:

Fixed support for OneToOneField, thanks limodou

Legend:

Unmodified
Added
Removed
Modified
  • DjangoGraphviz

    v9 v10  
    3131  $ python modelviz.py <app_label> > <filename>.dot
    3232
    33 Example:
     33Changelog
    3434
    35   $ python modelviz.py camera > foo.dot
     350.4
     36Fixed OneToOneField support (thanks, limodou)
     37
     380.3
     39Added support for GenericRelation and OneToOneField
     40
     410.2
     42Changed display (shape="record", thanks Malcolm Tredinnick),
     43fixed arrow direction, added display of model attributes
     44(thanks, Russell Keith-Magee)
     45
     460.1
     47First release.
    3648"""
     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   ]
    3757
    3858from django.db import models
     
    6484    label = "{%s |""" % (o.__name__, o.__name__))
    6585
    66       # members
     86      # model attributes
    6787      for field in o._meta.fields:
    6888         nodes.append('%s : %s\\l' % (field.name, type(field).__name__))
     
    7292            nodes.append('%s : %s\\l' % (field.name, type(field).__name__))
    7393
    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 
    7894      nodes.append(""" }"\n]\n""")
    7995      print "".join(nodes)
     
    8197      # relations
    8298      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
    83111      for field in o._meta.fields:
    84112         if isinstance(field, ForeignKey):
     
    102130                  rel.append(_rel)
    103131
    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 
    112132      print "\n".join(rel)
    113133
Back to Top