graph_models - enforcing explicit fields error

207 ملاحظات
پہلے نہ پڑھے ہوئے پیغام پر جائیں

luke....@lock8.me

نہ پڑھا ہوا،
23 دسمبر، 2015، 5:18:57 PM23/12/15
بنام 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 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 


Trbs

نہ پڑھا ہوا،
28 دسمبر، 2015، 2:10:44 AM28/12/15
بنام django-e...@googlegroups.com
Hi,

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.

Regards,
Trbs

--
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 django-extensi...@googlegroups.com.
To post to this group, send email to django-e...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-extensions.
For more options, visit https://groups.google.com/d/optout.

luke....@lock8.me

نہ پڑھا ہوا،
29 دسمبر، 2015، 10:41:42 AM29/12/15
بنام django-extensions،tr...@trbs.net
Hey, thanks for the reply. I just checked the github issues, and it's already there - https://github.com/django-extensions/django-extensions/issues/794
Will keep an eye on it from there. Thanks!
سبھی کو جواب دیں
مصنف کو جواب دیں
فارورڈ کریں
0 نئے پیغامات