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
Related
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.
I want to test my django app in my WAMP server. The idea is that i want to create a web app for aaa.com and aaa.co.uk, if the user enter the domain aaa.co.uk, my django app will serve the UK version, if the user go to aaa.com, the same django app will serve the US version (different frontend). Basically i will be detecting the host of the user and serve the correct templates.
How do i setup my WAMP so i can test this? right now i am using pyCharm default server which is 127.0.0.1:8000
Ok the answer is basically ericeastwood.com/blog/3/django-setup-for-wamp combined with httpd.apache.org/docs/2.4/vhosts/name-based.html – shadow
first install mysqliclient module using below command
pip install mysqlclient
open settings.py file and change database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'yourdbname',
'USER': 'dbusername',
'PASSWORD': 'your password',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
I have my Django project all saved in a virtual environment, and I'm using PostgreSQL. When I copied my virtual environment onto a second PC, I can not launch the project because of database authentication problems. I'm just wondering if it is possible to duplicate the project (with database) onto a second machine, and work on the development from two machines. Thanks in advance!
You need to create database with all of your credentials that located in settings.py file. And if you want, copy data from db on the first computer with pg_dump and then put that data on newly created database.
This is a very common situation. You could use multiple setting files to achieve this.
Let's say your project is myproject:
so in myproject/ you have:
- __init__.py
- urls.py
- wsgi.py
- settings.py
You could add a new file with your local configuration:
- local_settings.py
You can override database configuration in this file:
DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'newdatabase',
'USER': 'newuser',
'PASSWORD': 'newpassword',
'HOST': '127.0.0.1', # Or an IP Address that your DB is hosted on
# 'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
Then, add at the end of your original settings.py file:
try:
from .local_settings import *
except ImportError:
pass
Everywhere you carry your project you can create a new local_settings.py file with any new config you need.
Remember you can ignore this file (local_settings.py) in your github repository, so when you clone you project in a new PC you will just need to create a new local_settings.py and make you project run.
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".
I configured a postgressql database on ec2 instance. Now I want to talk to this database server using a different ec2 instance which is running a python/django framework.
My settings.py file contains:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USERNAME'],
'PASSWORD': os.environ['DB_PASSWORD'],
'HOST': os.environ['DB_HOSTNAME'],
'PORT': os.environ['DB_PORT'],
}
}
Where "DB_NAME" and other variables are defined in .ebextensions/*.config file under option_settings. When I push the code to AWS, the deployment log files shows that DB_NAME does not exists. I am not sure where I am going wrong. The Elasticbeanstalk console shows the variables though.