I'm using djanog version 1.11 and postgresql 9.5###,
I'm facing below error. but my django databases settings different.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME':'test_db',
'USERNAME':'rails',
'PASSWORD':'rails',
'HOST':'localhost',
'PORT':'5432',
}
}
I think django pass user as ubuntu user, it's system logged in user.
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x7f39fbfe5488>
Traceback (most recent call last):
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
self.check_migrations()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 422, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: password authentication failed for user "ubuntu"
FATAL: password authentication failed for user "ubuntu"
Your settings are wrong.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': '<db_name>',
'HOST': '<db_host>',
'USER': '<postgres_user>',
'PORT': '5432',
'PASSWORD': '<postgres_user_password>',
},
}
it's "USER" not "USERNAME"
Related
System check identified no issues (0 silenced).
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
February 17, 2021 - 19:52:27
Django version 3.1.6, using settings 'felix.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
C:\Users\FELIX\OneDrive\Desktop\Projects\django login2\felix\felix\settings.py changed, reloading.
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\threading.py", line 950, in _bootstrap_inner
self.run()
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\threading.py", line 888, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
self.check_migrations()
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 459, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\migrations\loader.py", line 216, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
if self.has_table():
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 234, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "C:\Users\FELIX\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
TypeError: connect() argument 4 must be str, not WindowsPath
I got similar error information while doing makemigrations, and str() worked.
# BASE_DIR = Path(__file__).resolve().parent.parent
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': str(BASE_DIR / 'my.cnf')
}
}
}
TypeError: connect() argument 4 must be str, not WindowsPath, parece referirse a que la línea 4 de la conexión tiene un formato no estándar para el path, solo es revisar el formato de la conexión a DB, por ejemplo:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'project_django_1',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': 3306,
}
}
when you are using mysql you do not needed to give the path just creat database and put the name of database
'ENGINE': 'django.db.backends.mysql',
'NAME': 'your-database-name',
Have you set mysql Database setting?
Please check you set DATABASE right.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dbname',
'USER': 'mysql username',
'PASSWORD': 'mysql user password',
'HOST': '127.0.0.1',
'PORT': 3306,
}
}
I am trying to switch the database settings of my Django application using environment variables. So I made few changes in my settings.py file like this -
print(os.environ.get('DATABASE'))
if os.environ.get('DATABASE') == "DEVELOPMENT":
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
else:
print("i m here")
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get('DATABASE_NAME'),
'USER': os.environ.get('DATABASE_USERNAME'),
'PASSWORD': os.environ.get('DATABASE_PASSWORD'),
'HOST': os.environ.get('DATABASE_HOST'),
'PORT': os.environ.get('DATABASE_PORT'),
},
}
Then I activated Python3 VirtualEnviroment and executed export DATABASE=DEVELOPMENT as shown in picture below -
When I start my application I get this from the print() -
None
i m here
None
i m here
It has also raised and exception -
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/core/management/base.py", line 395, in check
include_deployment_checks=include_deployment_checks,
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/core/management/base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/core/checks/model_checks.py", line 34, in check_all_models
errors.extend(model.check(**kwargs))
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/models/base.py", line 1274, in check
*cls._check_constraints(),
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/models/base.py", line 1840, in _check_constraints
connection.features.supports_table_check_constraints or
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/mysql/features.py", line 93, in supports_column_check_constraints
if self.connection.mysql_is_mariadb:
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 363, in mysql_is_mariadb
return 'mariadb' in self.mysql_server_info.lower()
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 350, in mysql_server_info
with self.temporary_connection() as cursor:
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 604, in temporary_connection
with self.cursor() as cursor:
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner
return func(*args, **kwargs)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 260, in cursor
return self._cursor()
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 236, in _cursor
self.ensure_connection()
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner
return func(*args, **kwargs)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner
return func(*args, **kwargs)
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 196, in connect
conn_params = self.get_connection_params()
File "/Users/jeetpatel/Desktop/env/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 206, in get_connection_params
if settings_dict['HOST'].startswith('/'):
AttributeError: 'NoneType' object has no attribute 'startswith'
I would like to know why is my if statement not working. Why am I not able to get the values from my environment variables.
I am using djongo with django2 to connect to mlab mongodb instance.
settings.py
'default': {
'ENGINE': 'djongo',
'NAME': 'neon',
'HOST': 'mongodb://username:password#ds249605.mlab.com:49605/mlab1',
}
}
although I am using this settings, the PyMongo connects to the local instance of mongodb.
log
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/core/management/base.py", line 453, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
if self.has_table():
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/backends/base/introspection.py", line 48, in table_names
return get_names(cursor)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/backends/base/introspection.py", line 43, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/djongo/introspection.py", line 47, in get_table_list
for c in cursor.db_conn.list_collection_names()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/database.py", line 856, in list_collection_names
for result in self.list_collections(session=session, **kwargs)]
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/database.py", line 819, in list_collections
_cmd, read_pref, session)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1454, in _retryable_read
read_pref, session, address=address)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1253, in _select_server
server = topology.select_server(server_selector)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/topology.py", line 235, in select_server
address))
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/topology.py", line 193, in select_servers
selector, server_timeout, address)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/topology.py", line 209, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
mLab
The host be inside client like this
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'fitbitt',
'CLIENT': {
'host':'mongodb://your_username:your_password#ds363008.mlab.com:63008/fitbitt',
'username':'your_username',
'password':'your_password'
}
}
}
Im trying to implement MongoDB in my Django app like this:
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'mongodb',
}
}
But I get this error:
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061]
No connection could be made because the target machine actively refused it
Traceback:
Traceback (most recent call last):
File "c:\users\...\appdata\local\continuum\anaconda3\Lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "c:\users\...\appdata\local\continuum\anaconda3\Lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "D:\Users\...\env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "D:\Users\...\env\lib\site-packages\django\core\management\commands\runserver.py", line 120, in inner_run
self.check_migrations()
File "D:\Users\...\env\lib\site-packages\django\core\management\base.py", line 453, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "D:\Users\...\env\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "D:\Users\...\env\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__
self.build_graph()
File "D:\Users\...\env\lib\site-packages\django\db\migrations\loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "D:\Users\...\env\lib\site-packages\django\db\migrations\recorder.py", line 73, in applied_migrations
if self.has_table():
File "D:\Users\...\env\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "D:\Users\...\env\lib\site-packages\django\db\backends\base\introspection.py", line 48, in table_names
return get_names(cursor)
File "D:\Users\...\env\lib\site-packages\django\db\backends\base\introspection.py", line 43, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "D:\Users\...\env\lib\site-packages\djongo\introspection.py", line 46, in get_table_list
for c in cursor.db_conn.list_collection_names()
File "D:\Users\...\env\lib\site-packages\pymongo\database.py", line 856, in list_collection_names
for result in self.list_collections(session=session, **kwargs)]
File "D:\Users\...\env\lib\site-packages\pymongo\database.py", line 819, in list_collections
_cmd, read_pref, session)
File "D:\Users\...\env\lib\site-packages\pymongo\mongo_client.py", line 1454, in _retryable_read
read_pref, session, address=address)
File "D:\Users\...\env\lib\site-packages\pymongo\mongo_client.py", line 1253, in _select_server
server = topology.select_server(server_selector)
File "D:\Users\...\env\lib\site-packages\pymongo\topology.py", line 235, in select_server
address))
File "D:\Users\...\env\lib\site-packages\pymongo\topology.py", line 193, in select_servers
selector, server_timeout, address)
File "D:\Users\...\env\lib\site-packages\pymongo\topology.py", line 209, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061]
No connection could be made because the target machine actively refused it
Thank you very much for any help
Check first that you passed through all these steps
Try changing port of mongodb , that will make it work hopefully :)
1) pip install djongo
2) DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'your-db-name',
}
}
3) python manage.py makemigrations
4) python manage.py migrate
I have a PostgreSQL database server which is read only transaction. I need to extract some from this database in Django. My setting.py file is given below:
{
{
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'supercaller',
'USER' : 'chandra_m',
'PASSWORD' : 'XXXXX',
'HOST': 'xx.xxx.xxx.xxx',
'PORT': '5432',
}
}
}
}
I am running the server with python manage.py runserver. I am getting following error
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x1aa9230>
Traceback (most recent call last):
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/utils/autoreload.py", line 222, in wrapper
fn(*args, **kwargs)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site -
packages/django/core/management/commands/runserver.py", line 107, in inner_run
self.check_migrations()
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/core/management/commands/runserver.py", line 159, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/migrations/executor.py", line 17, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/migrations/loader.py", line 48, in __init__
self.build_graph()
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/migrations/loader.py", line 179, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/migrations/recorder.py", line 59, in applied_migrations
self.ensure_schema()
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/migrations/recorder.py", line 53, in ensure_schema
editor.create_model(self.Migration)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/backends/schema.py", line 270, in create_model
self.execute(sql, params)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/backends/schema.py", line 98, in execute
cursor.execute(sql, params)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.InternalError: cannot execute CREATE TABLE in a read-only transaction
However, I am able to access this database server through a shell prompt with
psql -h 46.xxx.xxx.52 supercaller chandra_m
How to fix the errors?
you need to make sure your sessions are not using databases (default). I would consider leaving the 'default' to a writeable databaes, then add a 'readonly' database connection as an alternative connection for the objects that you are accessing in it.
First your log says, you have migrations that's not applied to the db you are connecting to, so fix it first.
Then I had success with the following in settings.py
SESSION_ENGINE="django.contrib.sessions.backends.cache"