I am trying to write a simple web application, where i can upload csv files and return the headers from each file. Everything is working fine. The id, the path to the file, gets saved in a database.
This is the response i am getting:
{
"id": 1,
"filefield": "http://127.0.0.1:8000/api/merged/1/uploads/header_body_test_zZr4Cea.csv"
}
What i do not understand is, where or how can i actually work with the data i request from the database? What i am imagining is a different url route, where i can specify an id and the response would be something like this:
{
"id": 1,
"filefield": "http://127.0.0.1:8000/api/merged/1/uploads/header_body_test_zZr4Cea.csv"
"headers_of_csv": "Date;Amount"
}
Its hard for me to explain (or google) what my problem actually is. I dont understand where or how the code to do this would actually be (is it part of the serializer, or the view, or in the model?).
Or even in simpler terms, lets say i have a model, that had an id and a 3 digit number and returns this:
{
"id": 1,
"number": 567
}
How or where could i create a respone like this:
{
"id": 1,
"number": 567
"first_digit_or_number": 5
}
Any help is greatly appreciated, i just dont understand what i am supposed to be looking for.