CODE:
from app.models import Bank banks_queryset = Bank.objects.all() # Convert the queryset to a list banks_list = list(banks_queryset) print(banks_list[0])
SOLUTION:
If you are running the python outside of the usual manage.py. you need to configure the environment variable "DJANGO_SETTING_MODULE". you can set it in your script before accessing the model.
UPDATED CODE:
import os import django os.environ.setdefault('DJANGO_SETTINGS_MODULE','quic_project.settings') django.setup() from app.models import Bank banks_queryset = Bank.objects.all() # Convert the queryset to a list banks_list = list(banks_queryset) print(banks_list[0])VIDEO GUIDE: