Add Postgres Cloud Database - Django Wednesdays ECommerce 43

preview_player
Показать описание
In this video we'll add the PostgreSQL database to our ecommerce app with Django and Python.

Up until now we've been using the basic SQLite3 database that comes with Django, but that's not appropriate for a live production website.

So we'll add a cloud Postgres Database to our app in this video that is fully online.

#django #codemy #JohnElder

Timecodes

0:00​​ - Introduction
2:27 - Pip Install Psycopg
4:21 - Railway Postgres Intro
7:00 - Get Railway Variables
8:38 - Pip Install Python-dotenv
9:03 - Import python-dotenv
9:26 - load_dotenv()
9:34 - Create .env and .gitignore files
10:25 - add variable to .env
12:00 - Migrate Tables
13:49 - Create Super User
15:17 - ReAdd Categories
15:40 - ReAdd Products
18:42 - Conclusion
Рекомендации по теме
Комментарии
Автор

Watch Django Wednesdays Ecommerce Playlist Subscribe To My YouTube Channel:
See More At: Join My Facebook Group:
Get The Code

Codemycom
Автор

Hey John!

I hope you are doing well.
Can I please ask for an AWS implementation of the database? Even if its just hooking it up and doing basic things with it.

I just really love AWS and use it for other projects and I'd like to be able to follow along with your tutorials and knowing how you do the things on railway, but I do it on AWS?

(even if it is just a random side-video completely outside of the series)

armandtvanzyl
Автор

hello Sir i have used all the same steps as you but still this error . I cannot understand what is the issue this is the issue
Microsoft Windows [Version 10.0.19045.4717]
(c) Microsoft Corporation. All rights reserved.

D:\Backend Development\Django 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\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\base\base.py", line 275, in ensure_connection
self.connect()
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\base\base.py", line 256, in connect
self.connection =

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\postgresql\base.py", line 277, in get_new_connection
connection =

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

psycopg2.OperationalError: could not translate host name "postgres.railway.internal" to address: No such host is known.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\commands\runserver.py", line 136, in inner_run
self.check_migrations()
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\base.py", line 581, in check_migrations
executor =

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader =

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\migrations\loader.py", line 58, in __init__
self.build_graph()
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph
self.applied_migrations =

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\migrations\recorder.py", line 89, in applied_migrations
if self.has_table():

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\migrations\recorder.py", line 63, in has_table
with self.connection.cursor() as cursor:

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\base\base.py", line 316, in cursor
return self._cursor()

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\base\base.py", line 292, in _cursor
self.ensure_connection()
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\base\base.py", line 274, in ensure_connection
with self.wrap_database_errors:
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\utils.py", line 91, in __exit__
raise from exc_value
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\base\base.py", line 275, in ensure_connection
self.connect()
File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\base\base.py", line 256, in connect
self.connection =

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\postgresql\base.py", line 277, in get_new_connection
connection =

File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

could not translate host name "postgres.railway.internal" to address: No such host is known.

however my host variable is same as on railway . I have used exact steps plus exact copied data from railway app

MuhammadAliAbbasKhan-uksk
Автор

I am having this stupid eror and ı couln't find any solution yet! So ı write here as well. if anybody knows how to fix this error. please help me out

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xf6 in position 79: invalid start byte

I checked any explanation but none works and again thank you for the course sir!!

ForRosS
Автор

I'm having an issue that i cannot find a solution.

conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
could not translate host name "postgres.railway.internal" to address: nodename nor servname provided, or not known

i'm on a macbook air m2

i'm from brazil

i tried running pg_isready, and i get 'accepting connections', however when i type in the host, i get 'no response'

please help

thank you

marcelo
Автор

thank you john and The site is slow before add postegres

OmarMuhammed-vk
Автор

Can I use MySQL instead of Postgres in this course ?

aminead
Автор

where are the videos to finish this project ? I have finished video 43 and I thought that there would be more, such as the payment system and launching the site from github.

pearlalexandralee
Автор

Hello I am Abhi from India and I watch your videos because I get to learn a lot from them. You made a video on deploy. I have many projects which are ready for deployment and there are many videos also but I am not able to understand their content.

abhiv
Автор

The best Python-Django Tutorial ever seen, thank u so

kevinbarrantes
Автор

awesome tutorial - thank you so much! will you be doing any stripe implementation?

OceanTheCat-fink
Автор

hi John,
I'm David from Nigeria,
just wanted to thank you for giving these courses for free, I've really learned a lot from them,
I just wanted your help with this error that keeps happening,
by the way, I've rewatched the video like 5 times so it's not from me,
I keep getting this error could not translate host name "postgres.railway.internal" to address: No such host is known",
I have gone online to see how to solve it but got nothing,
so can you find out what's wrong and get back,
thank you.

DavidAdegbite
Автор

You, my friend, are the best...thank you for the teachings!

scarplus
Автор

awesome tutorial - thank you so much! will you be doing any stripe implementation?

OceanTheCat-fink
Автор

Sir, do i understand correctly that we're doing this to make the website accessible online to anyone?

miniit-iygc
Автор

"Oh let's use AWS " ... ! And the doors to hell opened ! It's an arduous process to say the least !

TheLummen.
Автор

Even when I delete orders from the Django Admin payment>Orders area, the order numbers do not reset. For example, if I had 10 orders previously, then deleted all of them and created a new order after filling out the form, it assigns the new order number as 'Order - 11' instead of 'Order - 1'. How can I reset this issue?

usman_saadat
Автор

please can you add videos about django multi tenant?

alexdin
Автор

Hello John, I followed along and set up my code as provided by you. But I am encountering an error repeatedly. I looked for answers in the railway community, but in vain. I tried using LLMs and also tried connecting pgAdmin, but always got an error.

The terminal shows this error - could not translate host name "postgres.railway.internal" to address: No such host is known." Please let me know if you are aware of any solutions.

Thank You

rajbhatta
Автор

Please make a problem solving playlist!!

saadNDC