1

I have a django app that's file tree looks like this:

  • app1
    • ____init____.py
    • functions.py
    • management (dir)
      • ____init____.py
      • excel.py
      • commands (dir)
        • ____init____.py
        • importfromexcel.py

I have my most used methods in functions.py, and I want to use them in excel.py (from app1.functions import method1, method1, method3) , but here comes the issue.

When I run it like python manage.py importfromexcel, it works. But when I try to run the migrations with python manage.py migrate it gives import error:

    File "PATH_TO_DJANGO\app1\management\excel.py", line 3, in <module>
    from app1.functions import method1, method1, method3
    ImportError: cannot import name method1

What is wrong with my import? How should I import it if not this way?

MorRich
  • 426
  • 2
  • 5
  • 15
  • 1
    I'd guess it's a circular import error but need to see more code to make sure - Take a gander at http://stackoverflow.com/a/10027101/784648 – A. J. Parr Jun 24 '16 at 03:26
  • Thank you for the guide, it was really a circular import, I did not know about this. It is now solved, thanks! – MorRich Jun 26 '16 at 12:39

1 Answers1

0

I'd guess it's a circular import error but need to see more code to make sure - Take a gander at stackoverflow.com/a/10027101/784648 - @ARJMP

Community
  • 1
  • 1
MorRich
  • 426
  • 2
  • 5
  • 15