filipefigcorreia/django-extensions — pull request #1 by stephenmcd (2012-01-22 18:27:16+00:00)
Title: abstract-pks-in-graph-models

Thanks so much for your work on this, having abstract models in the graph has been a long-time wish for me, but something I never attempted to do.

I do get an error with your current version - it appears to break when trying to add primary keys for abstract models, which makes sense since the idea of a primary key doesn't really apply to these. This patch gets around it. I'm on OSX 10.7 with Python 2.7 and the latest graphviz, graphing the Mezzanine project (https://github.com/stephenmcd/mezzanine) - here's the traceback I get without my patch:

[1] $ ./manage.py graph_models -a -e -o graph.png ✘
Traceback (most recent call last):
File "./manage.py", line 35, in
execute_manager(settings)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django_extensions/management/commands/graph_models.py", line 41, in handle
dotdata = generate_dot(args, **options)
File "/Library/Python/2.7/site-packages/django_extensions/management/modelviz.py", line 286, in generate_dot
if pk in attributes:
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 124, in __cmp__
return cmp(self.creation_counter, other.creation_counter)
AttributeError: 'NoneType' object has no attribute 'creation_counter'