I installed djongo through pip. My django version is 3 although I checked version 2 also to make it work. Python version is 3. I also made change in settings.py but whenever I load the command with makemigrations, it gives me following error.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql','oracle','postgresql','sqlite3'
I don't know what to do with this now?
settings.py
DATABASES = {
default: {
'ENGINE': 'djongo',
'NAME' : 'django_db'
}
}
there's this awesome package that allows you to connect Django with MongoDB it's called mongoengine
http://mongoengine.org/
here's also a link for their documentation
http://docs.mongoengine.org/
Related
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!
Its been a few months that I am trying to learn Django. In the same process (and while reading "Two Scoops of Django 1.11"), I came across Cookiecutter Django. It has helped me learn a few important things to keep in mind while creating a project.
I tried to run the template provided by cookiecutter-django but failed. Here are the steps that I followed.
Create a virtual environment named test and activate it.
mkvirtualenv test
Installed Cookiecutter.
pip install coockiecutter
Installed Cookiecutter Django, The project name was set to "Test Project" and other defaults settings were chosen. I am using PostgreSQL 9.6.
cookiecutter https://github.com/pydanny/cookiecutter-django
Create a database named "test_project" in PostgreSQL.
Run python manage.py migrate
The result was the error:
django.db.utils.OperationalError: FATAL: role "dev" does not exist
I have also tried making a user named test_project_user and granting it all the privileges to test_project database. I am still getting the same error.
The problem seems to be that you specified a database user that does not exist (or you left blank and it assumes your system user), in:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'test_project',
'USER': 'HERE', # Set test_project_user here
...
}
}
Hi iam following Django documenatation,I have installed Django 1.8 and python 2.7.12,I want to connect to oracle 11g database,For this I have altered settings.py file in mysite folder like this for DATABASE information
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.oracle',
'NAME' : 'XE',
'USER' : 'chandan',
'PASSWORD' : 'root',
'HOST' : 'localhost', }
}
Iam getting below error when i run python manage.py runserver and
python manage.py migrate
from .utils import InsertIdVar, Oracle_datetime, convert_unicode
File "C:\PYTHON27\lib\site-packages\django\db\backends\oracle\utils.py", line 10, in <module>
(int(Database.version.split('.', 2)[1]) >= 1 or
ValueError: invalid literal for int() with base 10: '0rc1'
Do i have to alter my DATABASE part in settings.py or what needs to be done?
Firstly, check your connection for ORACLE.
Add port information.
Be sure to install cx_Oracle driver-lastest version.
You are running an incompatible oracle version, Django's oracle drivers tries to cast the version string as an int, which obviously fails as the oracle version string contains 0rc1.
You might want to install a newer release of Django, 1.8 is EOL and does not receive any security patches. And if you are starting a new project, do yourself a favor and choose Python 3 :-)
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
I'm trying to start a Django app to be hosted on GAE, using CloudSQL. Locally, I'm on Mac OSX Maverics, working within a virtualenv (via virtualenvwrapper).
After installing the GAE SDK for Python, I started my virtual environment, installed Django 1.5 from /usr/local/google_appengine/lib/django-1.5/
Also, on appengine.google.com I created a new app, and connected a CloudSQL instance to it (enable billing).
I'm able to create a new Django project, e.g. django-admin.py startproject test01, then I edit its settings.py to change the DATABASES definition per Google's instructions, e.g:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/myapp-test01:myapp-db-test01',
'NAME': 'test01',
'USER': 'test01',
}
}
I also added app.yaml to the root of the project folder, per Google's docs:
application: test01
version: 1
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: django
version: "1.5"
builtins:
- django_wsgi: on
This is where I hit roadblocks.
First: What exactly should be entered into the DATABASES for NAME and USER fields? The docs do not go into any detail.
Second, when I run: python manage.py syncdb to initialize the app, I get:
OperationalError: (2002, "Can't connect to local MySQL server through socket '/cloudsql/desgn-test-01:db-test-01' (2)")
I do have MySQL installed, via brew install mysql (although I didn't do that inside the virtual environment), and I also have MySQL-python.
I'm new to GAE and fairly inexperienced with setting up databases, so I'm not sure what do try next. I'm not sure if the issue is with my local MySQL, or the CloudSQL connection settings?
(A more general Django on GAE question: What is the workflow exactly? If I get the connection to work, does it mean that I am using CloudSQL even when developing my Django app locally? How do I subsequently "push" the app to the AppEngine, or make updates? I'm assuming this is done with the Launcher but what is the correlation between creating (adding) an app using the appengine.google.com dashboard, versus adding a new app in the local launcher? Quite confused by this -- are these two one and the same app, need to have identical names, or..?)
Looks like at the time, you were missing the password field as well...
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'test01',
'USER': 'test01',
'PASSWORD': '[password]',
'HOST': '/cloudsql/myapp-test01:myapp-db-test01',
'PORT': '3306',
}
Using the GUI for Cloud SQL, you can always add new Super Admin level users to the Cloud SQL instance in case you're unsure what user to use as well.