A simple project to simulate a news provider API. Made with Django, DRF and PostgreSQL.
Create new directory
mkdir news_provider
Change directory
cd news_provider/
Create virtual environment
python3 -m venv env
Activate virtual environment
# Windows:
env\Scripts\activate.bat
# On Unix or MacOS, run:
source env/bin/activate
Clone repository
git clone [email protected]:paultergust/news_provider.git
Change directory
cd news_provider
Install all dependencies
pip install -r requirements.txt
Make sure you have PostgreSQL runnint on port 5432. Then setup a database with credentials found in news_provider/settings.py:
# news_provider/settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': news_provider_api,
'USER': news_provider_api,
'PASSWORD': news_provider_api,
'HOST': localhost,
'PORT': 5432,
}
}
Run django migrations
python manage.py makemigrations
Run django server with specific settings file
python manage.py runserver --settings=news_provider/dev_settings
You'll need to have installed Docker, docker-compose and have a 'dockerd' instance running.
Clone repository
git clone [email protected]:paultergust/news_provider.git
Change directory
cd news_provider
After all set, just run:
make prod
OBS: If you get an error on this step, make sure you have port 5432 open. Maybe stop your local PostgreSQL service
sudo systemctl stop postgresql
- Login API:
/api/login/
- Sign-up API:
/api/sign-up/
- List articles:
/api/articles/?category=:slug
- Administrator restricted APIs:
- CRUD
/api/admin/authors/
- CRUD
/api/admin/articles/
- CRUD
{
"id": "39df53da-542a-3518-9c19-3568e21644fe",
"author": {
"id": "2d460e48-a4fa-370b-a2d0-79f2f601988c",
"name": "Author Name",
"picture": "https://picture.url"
},
"category": "Category",
"title": "Article title",
"summary": "This is a summary of the article"
}
{
"id": "2d460e48-a4fa-370b-a2d0-79f2f601988c",
"name": "Author Name",
"picture": "https://picture.url"
}
{
"username": "Username",
"password": "write-only hashed password",
"is_admin": false,
}