python -m venv env
Windows
env\scripts\activate
Linux
source env/bin/activate
pip install -r requirements.txt
DB_NAME={your_database_name}
DB_USER={your_database_user}
DB_PASS={your_database_password}
DB_HOST={your_database_host}
DB_PORT=5432
SECRET_KEY={secret_key}
- The secret key can be anything you want. But make sure it is at least 32 characters.
- You can create a key by using "openssl rand -hex 32"
- If you want to use sqllite not postgesql then comment the first "default" database and uncomment the next "default". It will create a new sqllite database on your project directory.
- You can also use POSTGRES image from docker.
docker run -d --name db -e POSTGRES_DB=mydatabase -e POSTGRES_USER=myuser -e POSTGRES_PASSWORD=mypassword -p 5432:5432 postgres:13-alpine
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
11. You can access the admin panel by this "127.0.0.1:8000/admin" and give the superuser username, password that you set earlier to see the admin panel.
docker pull mahadi025/group-chat-app
version: "3"
services:
app:
image: mahadi025/group-chat-app
command: sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
ports:
- "8000:8000"
depends_on:
- db
environment:
- DB_NAME=mydatabase
- DB_USER=myuser
- DB_PASSWORD=mypassword
- DB_HOST=db
- DB_PORT=5432
- SECRET_KEY=very-secret-key
db:
image: postgres:13-alpine
environment:
- POSTGRES_DB=mydatabase
- POSTGRES_USER=myuser
- POSTGRES_PASSWORD=mypassword
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
docker-compose up
docker compose run sh -c app "python manage.py createsuperuser"