I replaced all URLFields in the models with Cloudinary fields, and decided to drop the DB and make new, because issues appeared. So every migration file, accept init files was deleted, I dropped the DB, even deleted all containers and volumes(I use docker for PostgreSQL). I have made new images and containers in docker. New database. But still can't connect to database nad migrate.
This is the error:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more det ails.
This is my DB Settings:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'fishbook_db', 'USER': '*******', 'PASSWORD': '********', 'HOST': 'localhost', 'PORT': '5432', }, }
I have tried to fix the problem, by searching for this error in the web. I see a lot of people have the same problem, but I wasn't able to find solution so far.
Related
I've got a postgres DB which Django successfully connects to but when trying to create a new model I'm getting the error settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
I know settings.DATABASES is correctly configured as I've already created models which then Django used to create tables in the DB but for whatever reason it is now causing this error.
You can also see that I have already "supplied the ENGINE value".
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['POSTGRES_DB'],
'USER': os.environ['POSTGRES_USER'],
'PASSWORD': os.environ['POSTGRES_PASSWORD'],
'HOST': 'db',
'POST': '5432',
}
}
All help is appreciated.
Replace your ENGINE setting by:
'ENGINE': 'django.db.backends.postgresql'
It is the correct setting in Django 3 and up. See https://docs.djangoproject.com/en/3.0/internals/deprecation/#deprecation-removed-in-3-0.
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.
I'm creating a django web app that is going to be a database management portal for multiple databases. Because the web app will touch multiple databases, it doesn't make sense to have a default. However, when I run manage.py inspectdb I get an error saying that the ENGINE value isn't set on my database. It most definitely is.
Here's my DATABASES setting in settings.py
DATABASES = {
'default': {
},
'my_db': {
'NAME': 'my_db',
'USER': 'user',
'PASSWORD': 'pass',
'HOST': '192.168.0.255',
'PORT': '',
'ENGINE': 'sql_server.pyodbc',
'OPTIONS': {
'driver': 'ODBC Driver 13 for SQL Server',
},
},
}
If I run manage.py inspectdb using this setup I get this error:
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
This doesn't make sense to me, since it says in the documentation that 'default' can be a blank {}.
However, if I supply a dummy NAME and ENGINE variable to the default db, it seems to work fine for the default DB, but it ignores my_db.
If I set default to look at my_db's information I get a login error (so I know at least something is working right there, even if my creds are bad).
So, what am I getting wrong in my database setup here?
You need to specify a database for which you need to inspectdb
python manage.py inspectdb --database your_db_name
For more details see the docs
I want to set database setting in django project.
Which settings.py I should use.
I found many settings.py file.
I have setup devstack where many folders are there like horizon, cinder, nova etc.
I found settings.py in horizon folder.
and from when I setup Django I found in /usr/local/lib/python2.7/dist-packages/django/conf/project_template/project_name folder.
Please make suggest which settings.py I should use and
I can access database by user root with no database name giving in MySql Workbench.
Which database connection I should use?
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'nova',
'USER': 'root',
'PASSWORD': 'password',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
Please help..
You have to setup your DB in the settings.py file in horizon/openstack_dashboard folder .The DB name is devstack or any other name .All the django apps table will be created in a single DB
I am just starting to use MySQL as the database for my project. Previously I had been using SQLite.
I am wondering how to specify the location for the MySQL database the same way I was able to for SQLite. Currently it saves automatically to /usr/local/mysql/data by default. But I believe this will cause issues when I try to upload it to my production envroment.
My old SQLite settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'database/db.sqlite3'),
}
}
This saved the database into a database folder in my project which I was able to upload and chown both to www-data. This seems like a simple solution which I would like to replicate with MySQL
My new MySQL settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
#'NAME': 'django_db',
'NAME': os.path.join(BASE_DIR, 'database/django_db'),
'USER': 'root',
'PASSWORD': 'myPassword',
'HOST': 'localhost',
'PORT': '3306',
}
}
However when I try to syncdb with this I get the below error
django.db.utils.OperationalError: (1059, "Identifier name
'/users/user/workspace/bias_experiment/src/database/django_db'
is too long") (bias_experiment)localhost:src user$
I also tried to create the database within my project with
mysql> CREATE DATABASE /Users/user/workspace/bias_experiment/src/database/django_db;
But this gave me the error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/Users/brendan/Dropbox/workspace/bias_experiment/src/database/django_db' at line 1
mysql>
So can I create the DB with in my project and link to it in the same way as I did previously with SQLite? And If not what is the correct way/location to upload it to and link to it?
Any help is greatly appreciated
MySQL is not a file-based database: you don't give it a file path. In fact the settings file itself is quite clear about what you need to put in the NAME attribute, ie (not surprisingly) the name of the database itself. This is the same as you need for CREATE DATABASE, but again you don't give that a path: just a name.
You cannot access mysql files directly. You must create a database (give it a name, not a path) and access it.
SQL> CREATE DATABASE django_db
I'm trying to get a postgres database talking to a django installation.
I've followed the steps details here: http://blog.iiilx.com/programming/how-to-install-postgres-on-ubuntu-for-django/
However, when I use syncdb to have django update my postgres database, I receive the following error:
connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: FATAL: database "/home/flowcore/django_db"
does not exist
django_db is the name of the database and it DOES exist but of course it doesn't exist at /home/flowcore/django_db (that is not where postgres stores data!)
My databases dict in settings.py looks like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.path.join(BASE_DIR, 'django_db'),
'USER': 'django_login',
'PASSWORD': 'mypasswordhere', #obviously i've replaced this with my actual password
'HOST': 'localhost',
}
}
Do I have to specific an absolute path to my postgres database file and, if so, where are these files stored?
Well, for some reason you have put the full path as the NAME parameter, so it's not surprising that Django is using that. There's no reason to do that, and that tutorial you link to doesn't suggest it. NAME is the database name itself, which as you say is just "django_db".