graph_models - enforcing explicit fields error

Skip to first unread message

Dec 23, 2015, 5:18:57 PM12/23/15
to django-extensions
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 graph_models -a -o dbgraph.png

And getting the following error:

Traceback (most recent call last):
  File "", line 8, in <module>
  File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/", line 350, in execute_from_command_line
  File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/", line 342, in execute
  File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/lwm/velodrome/.venv/lib/python3.4/site-packages/django/core/management/", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/lwm/velodrome/.venv/src/django-extensions/django_extensions/management/", line 57, in inner
    ret = func(self, *args, **kwargs)
  File "/home/lwm/velodrome/.venv/src/django-extensions/django_extensions/management/commands/", line 77, in handle
    dotdata = generate_dot(args, cli_options=cli_options, **options)
  File "/home/lwm/velodrome/.venv/src/django-extensions/django_extensions/management/", 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/", line 217, in add_relation
    raise Exception("Lazy relationship for model (%s) must be explicit for field (%s)" % (field.model.__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


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?



Dec 28, 2015, 2:10:44 AM12/28/15

Could you make an issue for this on Github ? it's a bit easier to track that way.

Not sure why this limitation is there.. it could be we are just missing the code to do the lookup from string to model.


You received this message because you are subscribed to the Google Groups "django-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Dec 29, 2015, 10:41:42 AM12/29/15
to django-extensions,
Hey, thanks for the reply. I just checked the github issues, and it's already there -
Will keep an eye on it from there. Thanks!
Reply all
Reply to author
0 new messages