A fully integrated Docker + DJango + DJango REST Framework and OAuth2 + PostgreSQL application.
- Download & Install Docker and Docker-Compose
- Clone this repository with
git clone https://github.com/geevb/django-rest-app.git
- Access downloaded repository with cd
cd django-rest-app/
- Start containers with
docker-compose up -d db && docker-compose up -d web
- After the startup, run Django migrate to apply OAuth2 and PostgreSQL with
docker exec -ti django_1 python manage.py migrate
- Run
docker exec -ti django_1 python manage.py createsuperuser
and follow instructions to create a Super User.
- After creating the Super User, login with it at:
http://localhost:8000/admin/
- Then, create new Application here:
http://localhost:8000/o/applications/
- Fill the form with this config, save it
- Lastly, get both
CLIENT_ID
andCLIENT_SECRET
values and insert them atdjango_rest_app/settings.py
lines 137 and 138, respectively. Save the file.
- You can use Curl to test the endpoints, but it will be a lot easier if you import the
srCurriculos.postman_collection.json
into Postman. - The collection provided has all the methods pre-configured to all endpoints created in this application.
- Note that, the first endpoint that needs to be consumed is the
Add new user
with the body:
{
"username":"<Desired_Username>",
"password":"<Desired_Password>"
}
This will return the Access Token that needs to be used as authentication in every request after this as Bearer Token
.
To renew the token, use the Request auth. token
in the Postman Collection.
After everything's done, shutdown the Docker Containers by accessing the main folder django-rest-app/
and running docker-compose down
- Build and Run Django + Django REST with OAuth2 and PostgreSQL
- Expose endpoints to Create Users and Create, Edit, Remove Resumes.
- On every endpoint, the connection with PostgreSQL will be made, persisting the data as long as the Docker container is up.
- WEB UI to interact with the endpoints.
- Specific user roles and permissions
- Easier set-up