K
K
Kirill Petrov2018-08-08 22:02:24
Django
Kirill Petrov, 2018-08-08 22:02:24

Django doesn't import model from parent folder, why?

I want to import the model, but it says SystemError: Parent module '' not loaded, cannot perform relative import I
import it this way: What am I doing wrong, and how can I fix it?
from ..models import Articles

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Savelyev, 2018-08-09
@nikweter

Two dots mean you are moving up one folder hierarchy. I also recently encountered the same problem. I do not remember exactly, but the dock says about the prohibition to go beyond the package. Try replacing the dotted path with an absolute one - the folder with the application.models.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question