Circular import problem

18 views
Skip to first unread message

Daniel Oźminkowski

unread,
Apr 16, 2014, 5:37:13 AM4/16/14
to django...@googlegroups.com
Hello,

I recently cut my models.py into separate files and now I try to fix all the problems with imports that showed up. I hit the wall on this one though.

Purpose of the application is to process a text file with instructions and fit them into hierarchical structure like this:

Program <- Node <- Commands

Program has many Nodes, Nodes has many commands.

One of the possible Commands is jumping into subprogram. I want to get url of that subprogram, so I can show it in a template.

During analysis Program calls Node to create nodes. Node then calls Command to create Commands.

Then later Command takes the id of the subprogram and call Program.objects.get().get_absolute_url()

How can I break this import chain?

Best regards,
Daniel


Johannes Schneider

unread,
Apr 16, 2014, 6:40:16 AM4/16/14
to django...@googlegroups.com
You can use from foo import bar inside your method/class definitions or
you can use import foo.bar.

bg,
Johannes
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEW8F8Kv2GJ_f3mvP0mXhhDYj536%2BWwg6YMESd44efBec90Y3w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEW8F8Kv2GJ_f3mvP0mXhhDYj536%2BWwg6YMESd44efBec90Y3w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--
Johannes Schneider
Webentwicklung
johannes....@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
Reply all
Reply to author
Forward
0 new messages