I'm trying to setup mongodb on my nitrousio django box. Following this tutorial.
But when I try to start my django server I'm getting the next error:
action#django-box-25197:~/workspace/django/mysite$ python manage.py runserver 0.0.0.0:3000
ImproperlyConfigured: 'django_mongodb_engine' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of: u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: No module named django_mongodb_engine.base
action#django-box-25197:~/workspace/django/mysite$
I was reading about this error and I think that the Django-nonrel is not installed by default in the django's boxes and I want to know how can I use mongodb in my django box
Here is my dababase settings.py:
DATABASES = {
'default': {
'ENGINE': 'django_mongodb_engine', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': os.environ['MONGODB_DEVELOPMENT_DB'], # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': os.environ['MONGODB_DEVELOPMENT_USERNAME'],
'PASSWORD': os.environ['MONGODB_DEVELOPMENT_PASSWORD'],
'HOST': os.environ['MONGODB_DEVELOPMENT_HOST'], # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': os.environ['MONGODB_DEVELOPMENT_PORT'], # Set to empty string for default.
}}
Thanx in advance! :)
Related
I have been working on a Django app locally and it's now time to deploy it to a staging machine.
My Postgres database on the staging machine has a different username and password to my local machine.
I have got the Django app running okay on the remote machine, except that the database has not been initialised.
I assume that I should do this with migrate, so I try running:
$ python manage.py migrate
But I see the following error:
django.db.utils.OperationalError: FATAL: no pg_hba.conf entry
for host "127.0.0.1", user "mylocalusername", database "mylocaldbname"
It's failing because it doesn't allow me to log in with mylocalusername.
I assume that mylocalusername etc must be coming from the migrations files? Certainly the local username isn't set anywhere else on the staging machine, either in my settings file, or on the actual database itself.
How can I set up this database on the staging server?
I guess one way would be to delete everything in migrations and create a new local migration. Is that what I need to do?
I thought migrations were supposed to checked into source code, though, so I'd rather not delete all of them. Also, I want to carry on working on locally and updating my staging and production machines, so I need to find a sustainable way of doing this.
"mylocalusername" comes from settings.py file.
It should looks like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'mylocaldbname', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': 'mylocalusername',
'PASSWORD': 'password',
'HOST': 'localhost', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
}
You can change it or create a valid user in your postgres database.
./manage.py syncdb shows some error
(ENV)vijay#vijay-Ideapad-Z570:~/nightybuild/heroku-landing$ ./manage.py syncdb
ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
(ENV)vijay#vijay-Ideapad-Z570:~/nightybuild/heroku-landing$
in my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': '',
'PASSWORD': '',
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
but my app running successfully in heroku. when deploy its automatically heroku postgres confiqured. But in the local development its showing this error .
Can you please tell guide me how to set database for local?
What type of database are you using? Postgres, MySQL, SQLite? That will be your ENGINE value.
Also, what is your local postgres username and password? And your database name?
Below is an example with a postgres database named testdb with the username myusername and password mypassword:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'testdb',
'USER': 'myusername',
'PASSWORD': 'mypassword',
'HOST': '',
'PORT': '',
}
You may need to alter depending on your needs. The biggest change will likely be your ENGINE value. Change postgresql_psycopg2 to mysql if using MySQL or sqlite if using SQLite. Also, if using SQLite, you won't have values for USER and PASSWORD.
I've got a django project connected to a MySQL database as follows:
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'my_db',
'USER': 'username',
'PASSWORD': 'mypassword',
'HOST': '',
'PORT': '',
}
}
on running python manage.py syncdb, it creates the database and on runserver the application runs perfectly and I'm able to input data into the models using the admin panel correctly.
However, on trying to connect to the database using MySQL Workbench, it gives me
Can't connect to MySQL server on '127.0.0.1' (111) error.
I had created the database as follows:
Grant all on my_db.* to 'username'#'localhost' identified by 'mypassword';
flush privileges;
Why would Workbench show me that error even though the server is running correctly? Thanks in advance!
Edit: Used the word pythong.
I had similar issue but it got resolved by updating #port and #host into configuration file.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'vres', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': 'root',
'PASSWORD': 'root',
'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '3306', # Set to empty string for default.
}
}
It could be that your MySQL server is only listening to localhost.
In your my.cnf file, comment out bind-address.
#bind-address = 127.0.0.1
Restart your MySQL server and see if you can connect with Workbench.
I am starting to learn django , and I'm trying to set up a development environment as in http://www.venkysblog.com/setup-django-on-windows-with-apache-and-mysql. I'm having trouble getting it working and so I'm working backwards to make sure I have it all correct.
I'm ok up to step 4. I have confirmed python , xampp and django working . I have created a DB called django using phpmyadmin
I have a project called testproject, with the settings.py file including:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'post
'NAME': 'django', # Or path to database file if usi
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. No
'PORT': '', # Set to empty string for default. Not
}
}
when I run $ python manage.py runserver I get:
Validating models...
0 errors found
Django version 1.4.3, using settings 'testproject.settings'
Development server is running at htp://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Is there an explicit way to test the connection to 'django' db at this point?
Thanks in advance,
Bill
If you do manage.py syncdb it'll try to create your tables, and you'll know if it succeeded or failed.
I'm trying to create a database in my first Django project (called "meu_blog"). I've create a file called gerar_banco_de_dados.bat and type the following code inside:
python manage.py syncdb
pause
The code in the settings file of project "meu_blog" is:
DATABASES = {
'default': {
'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'meu_blog.db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
But when I tryed to create a user management system with the following information:
•Username: admin
•E-mail: admin#gmail.com
•Password: 1
•Password (again): 1
I get a message saying: “no fixtures found”
When, instead, it should appear this message (according to the tutorial book I'm following):
So, I'd like to know how to fix this "no fixtures found" and get the user management system installed.
I'm using Python 2.6 and Django 1.3.
Thanks in advance for any help.
"No fixtures found" is not an error, per se. That will often show up during syncdb if you're not using initial_data.json fixtures for your apps (which is not required). There is no problem.
The user system is already installed, according to your screenshots.
The fixtures arent installed, mostly because you did not provide any.
See here https://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-data-with-fixtures