-
Building a Todo App with a focus on Backend developemnt
-
Following DigitalOcean's Documentation to build out the basic Frontend in React and a Backend with Django
-
This was developed using WSL2 on a Windows machine, so all command line script will be written accordingly
I mean in the Documentation, the tutorial... never mind, bad dad joke
3rd command down didn't work work for me. I am using Pip3, so I used the pip3 command:
Install pipenv
with pip3
:
pip3 install pipenv
When you add the CORS_ORIGIN_WHITELIST
port for the frontend make sure and use a ,
after 'http://localhost:3000'
CORS_ORIGIN_WHITELIST = (
'http://localhost:3000',
)
In frontend/src/App.js
there is a missing /
at the end of the Axio Delete call
handleDelete = item => {
axios
.delete(`http://localhost:8000/api/todos/${item.id}/`)
.then(res => this.refreshList());
};
Change to a PostgreSQL database
Then install psycop2 for the PostgreSQL database
pip3 install pyscop2
Set up a PostgreSQL database with paAdmin locally on your machine or on some Linux server somewhere ElephantSQL AWS
In the setting.py
file in the backend
folder change the info under DATABASES
to this
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '5432'
}
}
Delete the db.sqlite3
file in the root folder and anything in the migrations
folder except for the __init__.py
file
python manage.py makemigrations todo
python manage.py migrate todo
py -m venv venv
venv/Scripts/activate
pip install django
pip install djangorestframework
pip install djangorestframework-simplejwt
pip install django-cors-headers
pip install -r requirements.txt
py manage.py makemigrations
py manage.py migrate
py manage.py createsuperuser
py manage.py runserver