Skip to content

How to set up django api

Joel Mathew Thomas edited this page Mar 25, 2025 · 6 revisions

This guide assumes that, you have already completed the steps in the guide Setting Up PyENV for this Repository. If not, do it before continuing.

Step 1: Install the dependencies for the api : django, celery, redis

 pip install -r requirements.txt

Step 2: Install Redis

Arch Linux

sudo pacman -S redis

Ubuntu

sudo apt-get install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis

Step 3: Start and Enable Redis Service

sudo systemctl start redis
sudo systemctl enable redis

Check the status to make sure Redis is running:

sudo systemctl status redis

Step 4: Navigate to django backend project directory

cd api/

Step 5: Start celery

celery -A backend worker --loglevel=info  

Step 6: Start daphne from the same venv

daphne backend.asgi:application