Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fandredev/django-api-rest
Basic API rest from students, courses and Matriculations using Python and Django Rest Framework
https://github.com/fandredev/django-api-rest
alura black django drf postgresql python
Last synced: about 1 month ago
JSON representation
Basic API rest from students, courses and Matriculations using Python and Django Rest Framework
- Host: GitHub
- URL: https://github.com/fandredev/django-api-rest
- Owner: fandredev
- Created: 2024-05-18T19:24:52.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T14:37:28.000Z (8 months ago)
- Last Synced: 2024-05-22T16:34:12.679Z (8 months ago)
- Topics: alura, black, django, drf, postgresql, python
- Language: Python
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Stack used
**Lint:** Black
**CI/CD:** Github Actions
## Authors
- [@fandredev](https://www.linkedin.com/in/devfandre/)
- [Alura](https://cursos.alura.com.br/formacao-django-rest)
# Installation:
## First, clone this repository.
```bash
git clone [email protected]:fandredev/django-api-rest.git
```## Create virtual environment with Python
```bash
python -m venv venv
```
## OR
```bash
python3 -m venv venv
```## Activate the virtual environment
```bash
source venv/bin/activate
```## Install dependencies using pip
```bash
pip install -r requirements.txt
```- Look the .env.example file to change your informations from PostgreSQL database.
A database must be created using PostgreSQL manually and your server needs be a running in other terminal.In example, i use asdf to instance postgres in my machine. (https://asdf-vm.com/)
![image](https://github.com/fandredev/django-api-rest/assets/49297012/ff27b012-8189-4410-819b-520301a7f4ce)
![image](https://github.com/fandredev/django-api-rest/assets/49297012/fde61b22-bc75-4b82-8aae-f7153c8dd200)## Run migrations to database
```bash
python manage.py migrate
```## Create a superuser
```bash
python manage.py createsuperuser
```
## Run development server
```bash
python manage.py runserver
```
- or using ```launch.json``` file (if you use vscode)## Run tests
```bash
python manage.py test
```## Open Django Admin
In another tab, open browser and put http://localhost:8000/control in URL browser. Log in with your superuser
## OPTIONAL (Populate your database using faker data)
```
python populate_students.py && python populate_courses.py
```## Use collection
Use DRF.postman_collection.json file to use Django Rest Framework routes
![Screenshot from 2024-05-18 17-58-06](https://github.com/fandredev/django-api-rest/assets/49297012/6d51ea14-f39c-48fa-9602-de3bbf994eb9)
- Pass, the user and password authorization to using routes (super/password that were created with ```python manage.py createsuperuser```)
![image](https://github.com/fandredev/django-api-rest/assets/49297012/0fa811c5-020d-44a9-a7c9-3351420c3beb)
- by default, the answers will come in .xml; Change this using 'Accept' header with 'application/json' value.
![Screenshot from 2024-05-22 19-12-41](https://github.com/fandredev/django-api-rest/assets/49297012/69969618-9888-4876-be17-40316acdf48f)- Note: to use students routes v2 use, http://localhost:8000/students?version=v2
## Feedback
If you have any feedback, please let us know via [email protected]
## Referencies
- [Django documentation](https://docs.djangoproject.com/en/5.0/)
- [Python](https://www.python.org/)
- [Black formatter](https://black.readthedocs.io/en/stable/the_black_code_style/index.html)
- [Alura Training](https://cursos.alura.com.br/formacao-django-rest)