Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django KeyError: "'__name__' not in globals"

Tags:

python

django

I've created an model Girl When I open python console and write from .models import Girl I get an error:

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

What do I do?

like image 786
user2950593 Avatar asked Mar 20 '17 01:03

user2950593


1 Answers

Did you try putting the app name before ".models"?

>> from [app_name].models import Girl
like image 63
user3750325 Avatar answered Oct 07 '22 22:10

user3750325