I am importing models in django shell API but i get the below error. Here is how it occurs:
python manage.py shell
from .models import Device
I get:
File "<console>", line 1, in <module>
KeyError: "'__name__' not in globals"
Try putting the app name before ".models". Here .models trying to import from models.py in the current directory but models.py is actually located in the app directory.
>> from [app_name].models import Device
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With