Hi folks,
I am working with python 3.X, django 1.9 and upstream django-extensions.
I am trying to run the following command:
python manage.py graph_models -a -o dbgraph.png
And getting the following error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
execute_from_command_line(sys.argv)
File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/lwm/velodrome/.venv/src/django-extensions/django_extensions/management/utils.py", line 57, in inner
ret = func(self, *args, **kwargs)
File "/home/lwm/velodrome/.venv/src/django-extensions/django_extensions/management/commands/graph_models.py", line 77, in handle
dotdata = generate_dot(args, cli_options=cli_options, **options)
File "/home/lwm/velodrome/.venv/src/django-extensions/django_extensions/management/modelviz.py", line 243, in generate_dot
add_relation(field, '[arrowhead=none, arrowtail=dot, dir=both]')
File "/home/lwm/velodrome/.venv/src/django-extensions/django_extensions/management/modelviz.py", line 217, in add_relation
raise Exception("Lazy relationship for model (%s) must be explicit for field (%s)" % (field.model.__name__, field.name))
Exception: Lazy relationship for model (OwnerableModelMixin) must be explicit for field (owner)
I, at the least, understand what I should do to fix this error. I should replace:
owner = models.ForeignKey('myapp.CustomUserModel', ...) # lazily defined
with:
owner = models.ForeignKey(CustomUserModel, ...) # explicitly imported
Right? However, I don't want to have to re order my entire models file just to get this to work. Also, there are other lazy relationships.
I'd like to
- a) Understand why this is the case. Why is this a limitation? Why does graph_models demand it is explicit?
- b) Is there a work around for this?
Thanks,
Luke