I've tried to connect my db. All db settings in settings.py is checked and they are correct. When I run the server, I face an error which is shown below. I searched at internet and I find solutions but all them is working for lower python version. I am using the newest python version. My error is that:
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 453, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
if self.has_table():
File "/Library/Frameworks/Python.framework/Versions/3.7/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 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 256, in cursor
return self._cursor()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 233, in _cursor
self.ensure_connection()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 197, in connect
self.init_connection_state()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 231, in init_connection_state
if self.features.is_sql_auto_is_null_enabled:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/mysql/features.py", line 82, in is_sql_auto_is_null_enabled
cursor.execute('SELECT ##SQL_AUTO_IS_NULL')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 103, in execute
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/mysql/operations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
This is an old issue about previous versions of django. It is currently 3.1.2 and the code block which causes the problem was fixed.
https://github.com/django/django/blob/master/django/db/backends/mysql/operations.py
You may try pip install -U django if your django version is newer then 3.0.0 (good)
Other choices are changing your django versions source code at related line in your virtualenv (ugly), or monkey patch the related function (bad)
Related
I am trying to connect the database mysql to mycode but i don't know what is the problen i have treid many solution but still confuse if any body can help ?
`
e:\hotelManagnment\customer.py:38: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
img2=img2.resize((100,40),Image.ANTIALIAS)
Traceback (most recent call last):
File "e:\hotelManagnment\customer.py", line 262, in <module>
obj=Cust_Win(root)
File "e:\hotelManagnment\customer.py", line 212, in __init__
self.fetch_data()
File "e:\hotelManagnment\customer.py", line 245, in fetch_data
conn=mysql.connector.connect(host="localhost",username="root",password="",database="managment")
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\pooling.py", line 287, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\connection.py", line 137, in __init__
self.connect(**kwargs)
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\abstracts.py", line 1108, in connect
self._open_connection()
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\connection.py", line 544, in _open_connection
self.set_converter_class(self._converter_class)
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\abstracts.py", line 1284, in set_converter_class
self.converter = convclass(charset_name, self._use_unicode)
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\conversion.py", line 136, in __init__
MySQLConverterBase.__init__(self, charset, use_unicode, str_fallback)
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\conversion.py", line 59, in __init__
self.set_charset(charset)
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\conversion.py", line 73, in set_charset
self.charset_id = CharacterSet.get_charset_info(self.charset)[0]
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\constants.py", line 775, in get_charset_info
info = cls.get_default_collation(charset)
File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mysql\connector\constants.py", line 746, in get_default_collation
raise ProgrammingError(f"Character set '{charset}' unsupported")
mysql.connector.errors.ProgrammingError: Character set 'utf8' unsupported
`
I have a Django project that connects to an Oracle database - implemented in PyCharm. I would like the app to monitor the connection and display a status as to whether the database is up or down. I stopped the listener to simulate an error. However, when I start the PyCharm server to test the functionality, the app immediately attempts a database connection and fails. Is it possible to defer the database connection until I can command one within the app?
Here is the error traceback on server startup:
C:\Users\steve\PycharmProjects\Tools\venv\Scripts\python.exe C:/Users/steve/PycharmProjects/Tools/Tools/manage.py runserver
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\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\oracle\base.py", line 229, in get_new_connection
return Database.connect(
cx_Oracle.DatabaseError: ORA-12541: TNS:no listener
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\steve\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Users\steve\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
self.check_migrations()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\core\management\base.py", line 486, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\migrations\executor.py", line 18, in init
self.loader = MigrationLoader(self.connection)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\migrations\loader.py", line 53, in init
self.build_graph()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
if self.has_table():
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\steve\PycharmProjects\Tools\venv\lib\site-packages\django\db\backends\oracle\base.py", line 229, in get_new_connection
return Database.connect(
django.db.utils.DatabaseError: ORA-12541: TNS:no listener
I'm trying to clone this Django repo and run it on my local machine, but I've run into the classic function() takes 1 positional argument but 2 were given error.
After cloning the repo I created a virtual environment and installed all the dependencies,
But when I run
py manage.py migrate
I get the above-mentioned error.
What's confusing me is that the error is occurring in a python file automatically generated in the virtual environment and according to other questions on SO about this, the code seems correct.
Here's the trace
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
django.setup()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django_prometheus\apps.py", line 22, in ready
ExportMigrations()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django_prometheus\migrations.py", line 39, in ExportMigrations
executor = MigrationExecutor(connections[alias])
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
if self.has_table():
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 202, in connect
self.init_connection_state()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\base.py", line 245, in init_connection_state
if self.features.is_sql_auto_is_null_enabled:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\features.py", line 150, in is_sql_auto_is_null_enabled
return self.connection.mysql_server_data['sql_auto_is_null']
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\base.py", line 366, in mysql_server_data
with self.temporary_connection() as cursor:
File "C:\Python\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 603, in temporary_connection
with self.cursor() as cursor:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 237, in _cursor
return self._prepare_cursor(self.create_cursor(name))
TypeError: create_cursor() takes 1 positional argument but 2 were given
Base.py in the virtual environment.
def _cursor(self, name=None):
self.ensure_connection()
with self.wrap_database_errors:
return self._prepare_cursor(self.create_cursor(name))
def create_cursor(self, name=None):
"""Create a cursor. Assume that a connection is established."""
raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a create_cursor() method')
I was hoping that someone could try cloning the repo and running it locally to see whether they could recreate the problem or maybe help me understand what's causing it.
I started Kiwi TCMS in Docker (k8s) with Postgresql. It started ok, but when I wanted to run migrations it crashed. I used this docker-compose for inspiration.
Log shows problem with connection with MySQL. But I changed configuration for engine. See:
bash-4.2$ KIWI_DB_ENGINE=django.db.backends.postgresql_psycopg2 /Kiwi/manage.py migrate
django.db.backends.postgresql_psycopg2
Traceback (most recent call last):
File "/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "/venv/lib/python3.6/site-packages/MySQLdb/__init__.py", line 85, in Connect
return Connection(*args, **kwargs)
File "/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Kiwi/manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 350, in execute
self.check()
File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 59, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/venv/lib/python3.6/site-packages/django/core/checks/database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "/venv/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "/venv/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor
return self._cursor()
File "/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor
self.ensure_connection()
File "/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/venv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "/venv/lib/python3.6/site-packages/MySQLdb/__init__.py", line 85, in Connect
return Connection(*args, **kwargs)
File "/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0")
Any ideas where can be problem please?
bash-4.2$ KIWI_DB_ENGINE=django.db.backends.postgresql_psycopg2 /Kiwi/manage.py migrate
django.db.backends.postgresql_psycopg2
This is setting an environment variable inside the docker container and I'm not sure if that works or which one takes precendece.
If you want somebody to help you post the entire docker-compose.yml (or whatever kubernetes control file you use). Clearly the application thinks it is configured to talk to MySQL and fails when MySQL isn't available.
So problem was with version of used docker image.
I used docker image tag kiwitcms/kiwi:6.2 and I thought it's the latest release. But it's not. This version(docker image) doesn't have code for changing DB engine. I changed version of docker tag to latest and it works pretty well now.
OS: Win 8.1
System: surface pro 3
python 2.7.9
postgre: 9.3
django 1.7.1
I am trying to complete the Ultimate Django tutorial: https://ultimatedjango.com/learn-django/lessons/handling-sensitive-keys/?trim=yes
On the section of sensitive keys it gives me the following errors when I run the server with : python manage.py runserver
CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.
Then on the settings.py i put :
ALLOWED_HOSTS = ['*']
and when I run the server again gives the following error:
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at
0x00000000035BD588
>
Traceback (most recent call last):
File "c:\venv\lib\site-packages\django\utils\autoreload.py", line 222, in
wrapper
fn(*args, **kwargs)
File "c:\venv\lib\site-
packages\django\core\management\commands\runserver.py",
line 107, in inner_run
self.check_migrations()
File "c:\venv\lib\site-
packages\django\core\management\commands\runserver.py",
line 159, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "c:\venv\lib\site-packages\django\db\migrations\executor.py", line 17,
in __init__
self.loader = MigrationLoader(self.connection)
File "c:\venv\lib\site-packages\django\db\migrations\loader.py", line 48,
in _
_init__
self.build_graph()
File "c:\venv\lib\site-packages\django\db\migrations\loader.py", line 179,
in
build_graph
self.applied_migrations = recorder.applied_migrations()
File "c:\venv\lib\site-packages\django\db\migrations\recorder.py", line 59,
in
applied_migrations
self.ensure_schema()
File "c:\venv\lib\site-packages\django\db\migrations\recorder.py", line 49,
in
ensure_schema
if self.Migration._meta.db_table in
self.connection.introspection.get_table_
list(self.connection.cursor()):
File "c:\venv\lib\site-packages\django\db\backends\__init__.py", line 167,
in
cursor
cursor = utils.CursorWrapper(self._cursor(), self)
File "c:\venv\lib\site-packages\django\db\backends\__init__.py", line 138,
in
_cursor
self.ensure_connection()
File "c:\venv\lib\site-packages\django\db\backends\__init__.py", line 133,
in
ensure_connection
self.connect()
File "c:\venv\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "c:\venv\lib\site-packages\django\db\backends\__init__.py", line 133,
in
ensure_connection
self.connect()
File "c:\venv\lib\site-packages\django\db\backends\__init__.py", line 122,
in
connect
self.connection = self.get_new_connection(conn_params)
File "c:\venv\lib\site-
packages\django\db\backends\postgresql_psycopg2\base.py
", line 134, in get_new_connection
return Database.connect(**conn_params)
File "c:\venv\lib\site-packages\psycopg2-2.6-py2.7-win-
amd64.egg\psycopg2\__in
it__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: fe_sendauth: no password supplied
Any help ?