A few notes that may be helpful to other beginners like me:
The docker-compose file should be saved as docker-compose.yaml
The docker-compose file didn't work as listed, but I changed line 11 to "POSTGRES_PASSWORD=demo" and that worked
Change the username/password on lines 27-28 of the docker-compose file to your own email address and a NON-PRIVATE password like "demo" or "password" since you're saving it in plain-text
The username and password on lines 27-28 are what you use to log in to pgadmin. The username and password on lines 10-11 are what you enter in the "Connection" tab when you're creating your database.
You have to pip install django_postgres_extensions in your django app environment before running runserver, or it won't work
AI entrepreneur specializing in creative video generation, with a strong focus on applying and discussing cutting-edge research to drive innovation in the field.
Location
Birmingham, United Kingdom
Education
University of Lagos, Nigeria
Work
Director @ Openwit Technologies | Technical Lead @ LSEG
Micheal, I am not sure exactly how to thank you for this article.
Over the last 24 hours, I have been following articles that use the postgres docker container name as the host while connecting to pgadmin and been unable to connect. 24 hours, and I have been pulling my hair out wondering what the hell I was doing wrong.
Thank you. Thank you so much for sharing your knowledge. I can sleep now.
Hello, i've been following your instruction but unfortunately I am having some issues which are not mentioned here.
File "C:\Users\Yonatan.virtualenvs\LMS-NZATbBlN\lib\site-packages\django_postgres_extensions\models\expressions.py", line 2, in
from django.utils import six
ImportError: cannot import name 'six' from 'django.utils' (C:\Users\Yonatan.virtualenvs\LMS-NZATbBlN\lib\site-packages\django\utils_init_.py)
This is the error i'm having about some module named "six".
Do you know how to solve this problem?
Haven't found any good answer online
Great informations, thanks a lot. I have a question: how can I connect other docker files to Django like what you did with Postgres? I mean how can I connect and consume other model like YoloV5 docker image inside docker?
sudo docker exec -it python manage.py migrate
but the django HOST variable in the container must be set to
HOST=db
and if you've bind-mounted your code into the container, you can do it directly from the console in your IDE (e.g. vscode) since the container is sharing the exact same code. BUT here HOST=localhost. This means you have to have separate environment variables set. Confusing, but that's what I've noticed.
A few notes that may be helpful to other beginners like me:
Hi Micheal thanks. I have a question I have seen some other examples where one does the following:
Based on your example above in the
docker-compose.ymlfile under the db service what is the difference?Micheal, I am not sure exactly how to thank you for this article.
Over the last 24 hours, I have been following articles that use the postgres docker container name as the host while connecting to pgadmin and been unable to connect. 24 hours, and I have been pulling my hair out wondering what the hell I was doing wrong.
Thank you. Thank you so much for sharing your knowledge. I can sleep now.
This is exactly what I needed. Thank you for sharing
Thanks, I am glad it helped
Thanks Michael, you saved me a lot of time!
You are welcome Guillermo
Hello, i've been following your instruction but unfortunately I am having some issues which are not mentioned here.
File "C:\Users\Yonatan.virtualenvs\LMS-NZATbBlN\lib\site-packages\django_postgres_extensions\models\expressions.py", line 2, in
from django.utils import six
ImportError: cannot import name 'six' from 'django.utils' (C:\Users\Yonatan.virtualenvs\LMS-NZATbBlN\lib\site-packages\django\utils_init_.py)
This is the error i'm having about some module named "six".
Do you know how to solve this problem?
Haven't found any good answer online
Great informations, thanks a lot. I have a question: how can I connect other docker files to Django like what you did with Postgres? I mean how can I connect and consume other model like YoloV5 docker image inside docker?
how to migrate?
sudo docker exec -it python manage.py migrate
but the django HOST variable in the container must be set to
HOST=db
and if you've bind-mounted your code into the container, you can do it directly from the console in your IDE (e.g. vscode) since the container is sharing the exact same code. BUT here HOST=localhost. This means you have to have separate environment variables set. Confusing, but that's what I've noticed.
Hi Micheal, how does one connect to a local MYSQL client using docker compose? If we dont' want to use mysql container?