c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
Python

Requested setting INSTALLED_APPS, but settings are not configured. You must either define..

| | django
I got this following error while running the python outside of the usual manage.py commands.

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: