Questo progetto ha scopo puramente didattico.
-
add auth (JWT)
-
improve error handling
-
create a new entity
python manage.py startapp <entity name>
- create a new migration
python manage.py makemigrations
- apply migrations
python manage.py migrate
- run server
python manage.py runserver
- genera secret key per auth
python -c "import secrets; print(secrets.token_urlsafe(32))"
# Output: kJ8Hn3L9pQ2mR5tW7xZ1aB4cD6eF8gH0- Crea un superuser (impostazione guidata):
python manage.py createsuperuser
# Username: admin
# Email: admin@example.com
# Password: ****- Inspect db throught Django
python manage.py dbshell
- Inspect db
sqllite3 db.sqlite3 # db is the db name
- Format code
ruff format .
- Check imports
ruff check .
curl -X GET http://127.0.0.1:8000/tasks/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>"curl -X POST http://127.0.0.1:8000/api/token/ \
-H "Content-Type: application/json" \
-d '{"username": "USER_NAME", "password": "PASSWORD"}'