0

I was making a django application .When i tried to import the models.py module in forms.py by the following command from . import models it raises the following error

Traceback (most recent call last):
  File "E:\practise_project\practise_app\forms.py", line 1, in <module>
    from . import models
SystemError: Parent module '' not loaded, cannot perform relative import

The directory structure is shown in the image.enter image description here

Sahib Navlani
  • 68
  • 1
  • 12
  • Just use `import models` – Rahul Mar 18 '16 at 05:45
  • Possible duplicate of [Relative imports in Python 3](http://stackoverflow.com/questions/16981921/relative-imports-in-python-3) – pixis Mar 18 '16 at 05:47
  • to test the package you need to run a script outside of the package and `import practise_app.forms` for example. Or if forms.py should be runnable as main you can add a check: `if __name__ == "__main__":import models ; else:from . import models` – Tadhg McDonald-Jensen Mar 18 '16 at 05:48

0 Answers0