I changed to postgres. anyway It gives the same error.
/usr/local/lib/python3.11/site-packages/django/core/management/commands/makemigrations.py:160: RuntimeWarning: Got an e
rror checking a consistent migration history performed for database connection 'default': could not translate host name "postgres" to address: T
emporary failure in name resolution
This error seems to be talking about migration history so I think you should check your ‘makemigrations & migrate’ commands or even clean-up your ‘migrations’ folder (leaving __init__.py) and running the commands again.
you know bro I do not have any migrations folder. I am new in this field so I have faced so many issues. If I ask any simple questions please don’t get angry.
I pulled the initial project from github. and added .env file. After this I run this command docker compose build it seemed good. then I run docker compose up and got the above error.
If that’s what you’ve pulled from some git repo, then the original author failed to push the migration files along with the code.
You’ll need to run a manage.py makemigrations book general users to create the necessary migration files, then run manage.py migrate
One of the possible issues you’re facing here is that your code for the makemigrations is running before the postgres is fully up-and-running. You may want to introduce some kind of delay or “monitoring program” to cause this command to wait until after the database has been initialized.
Finally, you do not want to use runserver to run your application.
Now it is working but when I run docker compose build it does not install the modules from requirements.txt. For this reason I cannot create superuser. When I try to create it says import error.
To work this docker I changed some files. I am providing those codes below.
Correct, because you’re now trying to run manage.py from outside your container environment.
Additionally, by shutting down your containers, postgres is no longer running. So when you’re trying to run createsuperuser, you don’t have a database available.
So, for the first time, I am working on a project as a team. Previously, I was doing projects by creating environments only through “venv”. I learned docker for this project. They prepared the initial part of the project and uploaded it to GitHub. I pulled a project from GitHub and I needed to run this project on my computer by creating an environment through Docker. Now, I used docker and now it doesn’t get the required modules from the “requirements.txt” file. Currently, the project is in the initial stage, we are implementing the bot project. We planned to make the bot admin panel in Django. I don’t need to deploy the project anywhere yet, I just need to use it properly in the local system.
Build your “bot” container such that you have a shell available that would allow you to execute commands from a shell within that container.
Build a separate container for running manage commands and use it for running those commands.
Configure a virtual environment in your host system with your application, and configure your installation to use the postgres docker container as the database. (This may or may not be easy, depending upon how postgres is configured in its container.)
You mean to run only postgres without running the bot container from the “docker-compose.yml” file. I have to start the server with venv environment created right?