I am currently working on a multi-tenant django application. Since the requirement of multi-tenancy, for starters, I have created a second database. However, I am unable to create a SuperUser in the newly created database.
I did try the answer listed Django fails to create superuser in other db than 'default'
However, no luck.
Getting the following output on compile:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly co
nfigured. Please supply the ENGINE value. Check settings documentation for more
details.
Settings.py
DATABASES = {
'default': {},
'Alora': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Alora',
'USER': 'postgres',
'PASSWORD': 'somepassword',
}
}
Python Version
C:\Users\User>python --version
Python 3.6.3
Django Version
C:\Users\User>django-admin --version
2.2
Tried python manage.py createsuperuser --database=Alora.
Received the error stated above.
Any help is deeply appreciated.
Thanks!
Related
I am trying to setup PostgreSQL locally on my computer, but when I try to initially set up my Django application with it using python manage.py makemigrations, I am given this warning:
RuntimeWarning: Got an error checking a consistent migration
history performed for database connection 'default': fe_sendauth: no password supplied
My database table in my settings.py is as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get("DB_NAME"),
'USER': os.environ.get("DB_USER"),
'PASSWORD': os.environ.get("DB_PASSWORD"),
'HOST': os.environ.get("DB_HOST"),
'PORT': os.environ.get("DB_PORT"),
}
}
My .env file is located in the same directory as my manage.py file:
DB_NAME=Smash
DB_PASSWORD=root
DB_USER=SmashDatabase
DB_HOST=localhost
DB_PORT=5432
DEBUG=1
I tried following this link's instructions but none of the offered solutions fixed the problem. I don't know what is wrong or what causes this issue.
Forgive me as I this is my first django project using postgresql (version 11.8). For now I just want to connect to a test database which I have set up locally using pgadmin4. When I create the database I am not given the option to add a password, but when I run python manage.py migrate it is insisting on a password. When I then set the password to "password" on pgadmin, django won't accept it. It's probably something really obvious as I am quite new to Django, but I have tried searching and not found the answer to my problem. In settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'test1',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
Last line of the error when I run python manage.py migrate:
django.db.utils.OperationalError: fe_sendauth: no password supplied
Any help much appreciated. Craig
When you installed PgAdmin4 it asked you to create a password. This is for the superuser postgres, which is what you are trying to connect as. Use psql to connect to the database using the above settings and supply the password and see if it works.
I resolved it by removing the Postgresql 11 server and reinstalling it.
I am currently building a web project in Django and working on getting the site ready for deployment. I initially deployed the site on Heroku using Sqlite3, with my database code in settings as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
However, due to Heroku's ephemeral file system I realized I needed to switch to Postgres. After following a few different guides I arrived at the following changes to my settings. I first deleted the "DATABASES" as mentioned above and replaced it with the following:
import dj_database_url, psycopg2
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': *************,
'USER': **************,
'PASSWORD': ************************************,
'HOST': *********************,
'PORT': '5432',
}
}
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
When I make these changes everything works perfectly on the local Django development server (127.0.0.1:8000), but once I push the changes through Git and to Heroku I try opening my site on Heroku and get "Application Error" and a suggestion to check my logs. Which report "ModuleNotFoundError: No module named dj_database_url" and similarly any outside library I try to upload to Heroku appears to have this issue. How can I fix this issue and move my site into production? Any help would be greatly appreciated.
You need to include them in your requirements.txt file or however the buildpack you're using expects the applications dependencies to be indicated.
am new to python and django
I am trying to build a small python django application on my local windows laptop.
i am not able to underlying tables required for my Django project as when i run "python manage.py syncdb" i get the below error
` Error :django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python? '
And when i try running "pip install mysqlclient" i get the below error
'error: Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.microsoft.com/download/details.aspx?id=8279'
I am stuck in this step and not able to find any leads. can someone suggest any workaround
By default Django is configured to use Sqlite database. See settings.py file:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
You have it configured to use MySQL database:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DATABASE_NAME',
'USER': 'DB_USERNAME',
'PASSWORD': 'DB_PASSWORD',
'HOST': '127.0.0.1',
'PORT': '3306'
}
}
If it's a small test project, I would recommend you to switch back to Sqlite, but if you intend to run your project later in production using MySQL, then better use MySQL in development process.
Install:
MySQL or MariaDB locally on your computer
Windows SDK from www.microsoft.com/download/details.aspx?id=8279
run pip install mysqlclient - now it should succeed
OS : CentOS 6.4
python version 3.4
django version 1.8
I had studies about django framework. Then, I going to move to storage part. At first of study, the default database is sqlite. So I was change some values in the settings.py file.
#DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
#}
DATABASES = {
'default' : {
'ENGINE' : 'mysql.connector.django',
'NAME' : 'dj_mysql',
'USER' : 'root',
'PASSWORD' : '',
'HOST' : '127.0.0.1',
'PORT' :''
}
}
I typed "python3 manage.my migrate", and I got these errors.
How can I overcome this situation. TT;
I'm struggling all day long.
It looks like you're trying to use MySQL connector. The Django docs suggest that it doesn't always support the latest version of Django. This bug report suggests that 2.1.3 supports Django 1.8, but users were still reporting problems with 2.1.3 on that bug report and in this question.
The Django docs recommend that you use mysqlclient to access MySQL databases with Django.
It's easy to install, for example with pip:
pip install mysqlclient
Then all you need to do is change your databases setting to
DATABASES = {
'default' : {
'ENGINE' : 'django.db.backends.mysql',
...
You should update the mysql-connector-python, since the old version don't support Django 1.8 well.
As the documentation of Django goes:
MySQL Connector/Python is available from the download page. The Django >adapter is available in versions 1.1.X and later. It may not support the >most recent releases of Django.
Use the following command to update it from the MySQL website:
pip install http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz