- Python (Django)
- Django REST API
- MySQL
- Clone this repository
cd
into the project root- Install dependencies with
pip-sync
- Create a MySQL user with database CREATE rights. Note the username and password
- Create a MySQL database, for the project, and assign it to the user above
- Create a file named
.env
at the root of the project and add the following (fill in values where you see<..>
):
DATABASE_URL="mysql2://<username>:<password>@localhost/<database name>"
SECRET_KEY="<a random string of letter, numbers and punctuation>"
- Activate the virtual environment with
source .venv/bin/activate
- Start the application with
./manage.py runserver
The app should start running via port8000
The following actions are supported via the REST endpoints:
- Student Creation/Reading/Updating/Deletion
- Teacher Creation/Reading/Updating/Deletion
- Assigning students to a teacher
Note: Remember to always append a slash to the URLs
GET /students/
GET /students/
POST /students/ pay load:
{
"name": "john",
"surname": "smith"
}
PUT /students// payload:
{
"name": "name",
"surname": "surname"
}
DELETE /students// payload: none
GET /teachers/
GET /teachers/
POST /teachers/ payload:
{
"name": "teacher name"
}
PUT /teachers// payload:
{
"name": "new name"
}
DELETE /teachers//
POST /teachers//students/ payload:
[
{"name": "name 1", "surname": "surname 1"},
{"name": "name 2", "surname": "surname 2"}
]
GET /teachers//students/ response: Array of students
The entry point is at http://127.0.0.1:8000/academia/