Django KeyError: "'__name__" not globally "

I created a Girl model. When I open the python console and write, from .models import Girl I get an error message:

>>> from .models import Girl
Traceback (most recent call last):
  File "<console>", line 1, in <module>
KeyError: "'__name__' not in globals"

What should I do?

+4
source share
1 answer

Have you tried putting the application name before ".models"?

>> from [app_name].models import Girl
+9
source

Source: https://habr.com/ru/post/1672695/


All Articles