I started learning Django some weeks back and i am encountering a particular error.
Import Error: cannot import Room from partially initialized module.
Pls how can I fix this, have been to stackflow and other sites I can not find the solutions
I started learning Django some weeks back and i am encountering a particular error.
Import Error: cannot import Room from partially initialized module.
Pls how can I fix this, have been to stackflow and other sites I can not find the solutions
It looks like you have a circular import. The module ola.views
probably imports ola.models
either directly or through a chain of imports which makes an import loop. This is a problem because normally you cannot import the same module again before the first import finished (the execution reached the end of the module file).
Probably the best practice is to split the modules in a way that the required imports make a tree dependency structure (without loops).
Hello @vbrozik,
I am facing the same error, how can I do split the modules in a way that the required imports make a tree dependency structure (without loops) ?
can you elaborate please !
Thank you
Best regards
Oussama
The basic way:
Normally an experienced programmer keeps this in mind during designing the code structure to limit the need for future refactorings. It is a good idea to draw (or imagine) a diagram of objects and their dependencies before we start programming them.