Django DB Settings 'Improperly Configured' Error
You can't just fire up Python and check things, Django doesn't know what project you want to work on. You have to do one of these things:
- Use
python manage.py shell
- Use
django-admin.py shell --settings=mysite.settings
(or whatever settings module you use) - Set
DJANGO_SETTINGS_MODULE
environment variable in your OS tomysite.settings
(This is removed in Django 1.6) Use
setup_environ
in the python interpreter:from django.core.management import setup_environ
from mysite import settings
setup_environ(settings)
Naturally, the first way is the easiest.
settings.DATABASES is improperly configured” error django 3.1 while running inspect db
I got it working using the below command for inspect db
python manage.py inspectdb --database population_db population > model.py
Q: Django ImproperlyConfigured - from django.contrib.auth.models import User
If this is Django, and not flask as the vega_flask_run.py
name implies then you need to run python manage.py runserver
to start the application.
This might be a duplicate of Django ImproperlyConfigured for import User.
Also, models.py
is not a script your run in django in the manner I think you're saying. It is where the models you define, the classes, for your project are located.
I may be the one missing something. Maybe you can edit your question with the vega_flask_run.py
file. Perhaps you're using it in a way that I'm just not familiar with.
Otherwise, I suggest you start with https://docs.djangoproject.com/en/4.0/intro/tutorial01/. I mean it looks like you've already started the project correctly since you have the django files there. Maybe it's just a matter of how you start them.
Edit
Yes, now I can see that you're trying to run a djagno app as if it were a flask app, app = Flask(__name__, ...
. Despite both Flask and Django being python frameworks, they are run very differently.
Django - settings.DATABASES is improperly configured. Please supply the ENGINE value
Turns out I'm an idiot.
I'm using docker and I forgot that I need to enter the container to do DB migrations ♂️
The exact cause of this error is that the dockerfile creates an environment variable called "DJANGO_SETTINGS_MODULE" which Django looks for and the value is the name of an alternate file to be used for settings. As I wasn't in the docker container, this environment variable wasn't available so it was using the default settings.py which has had its DB settings removed.
How can I solve the ImproperlyConfigured error in Django
Seems you are just running python
. You need to access shell as below.
python manage.py shell
Related Topics
Splitting a Pandas Dataframe Column by Delimiter
Pyinstaller and --Onefile: How to Include an Image in the Exe File
How to Scroll Frame Using Mouse Wheel & Adding Horizontal Scrollbar
Multiple Variables in a 'With' Statement
Could Not Find a Version That Satisfies the Requirement Tensorflow
Python - Is a Dictionary Slow to Find Frequency of Each Character
Replicating Rows in a Pandas Data Frame by a Column Value
How to Disable a Pylint Warning
How to Dynamically Create Derived Classes from a Base Class
Reading a Binary File with Python
Flask to Return Image Stored in Database
How to Have Assignment in a Condition
Paramiko Ssh Die/Hang with Big Output
How to Set Class Attributes from Variable Arguments (Kwargs) in Python
Character Reading from File in Python
How to Make a Selenium Script Undetectable Using Geckodriver and Firefox Through Python
Pandas Groupby and Select Rows with the Minimum Value in a Specific Column
"Importerror: No Module Named" When Trying to Run Python Script