django-extensions/django-extensions — pull request #198 by ciciliati (2012-04-18 12:00:50+00:00)
Title: Fixed issue with models containing self-relationships.

When running ./manage graph_models on an app containing models with self relationships we get the following error:

"""
Traceback (most recent call last):
File "./manage.py", line 14, in
...
File "/usr/local/lib/python2.6/dist-packages/django_extensions-0.8-py2.6.egg/django_extensions/management/commands/graph_models.py", line 41, in handle
dotdata = generate_dot(args, **options)
File "/usr/local/lib/python2.6/dist-packages/django_extensions-0.8-py2.6.egg/django_extensions/management/modelviz.py", line 258, in generate_dot
add_relation(field, '[arrowhead=none, arrowtail=dot]')
File "/usr/local/lib/python2.6/dist-packages/django_extensions-0.8-py2.6.egg/django_extensions/management/modelviz.py", line 237, in add_relation
'target_app': field.rel.to.__module__.replace('.', '_'),
AttributeError: 'str' object has no attribute '__module__'
"""

In these cases, "field.rel.to" contains the string "self".