Hey there!
I am new to coding and trying to build an app to learn. However I am having this error when ı wish to connect a remote postgres database. I am sure that ı am not using any character that doesnt fit utf-8 but somehow having this error. I check the similar problems here, Stackoverflow, youtube etc. but could’nt make sense. I would much appreciate anyhelp and explanation. I do understand it is a char_set issiue but ı checked a lot if there is a mistake but as far as ı can see no. I even put settings.py to chatgpt if there is a mistake for that regard but nope
Thank you very much!
C:\Users\cetin\OneDrive\Masaüstü\ecom\ecom\ecom\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:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib\threading.py", line 1075, in _bootstrap_inner
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib\threading.py", line 1012, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\core\management\commands\runserver.py", line 137, in inner_run
self.check_migrations()
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\core\management\base.py", line 581, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\migrations\loader.py", line 58, in __init__
self.build_graph()
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\migrations\recorder.py", line 89, in applied_migrations
if self.has_table():
^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\migrations\recorder.py", line 63, in has_table
with self.connection.cursor() as cursor:
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\backends\base\base.py", line 320, in cursor
return self._cursor()
^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\backends\base\base.py", line 296, in _cursor
self.ensure_connection()
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\backends\base\base.py", line 279, in ensure_connection
self.connect()
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\backends\base\base.py", line 256, in connect
self.connection = self.get_new_connection(conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\django\db\backends\postgresql\base.py", line 350, in get_new_connection
connection = self.Database.connect(**conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cetin\OneDrive\Masaüstü\ecom\virt\Lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 79: invalid start byte
settings.py
DATABASES = {
'default': {
#'ENGINE': 'django.db.backends.sqlite3',
#'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'railway',
'USER': 'postgres',
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': 'postgres.railway.internal',
'PORT': '5432',
}
}