i hope everyone is doing good.
So, there is an article api containing different parameters including documents model parameter.
Documents model is connected to article model using many to many field.
The current data that is coming is this
[
{
"id": 2,
"headline": "Article 2",
"abstract": "Abstract 2",
"content": "Content 2",
"published": "2022-08-10T11:28:04.351030Z",
"status": true,
"get_tags": [
{
"id": 1,
"tag": "Python"
},
{
"id": 2,
"tag": "Django Rest Framework"
}
],
"file_documents": [
{
"id": 2,
"document": "http://127.0.0.1:8000/images/tags-Many_RMVHBid.png"
}
],
"created_by": "dummyTest"
}
]
Now here what i want to ask is
"file_documents": [
{
1
}
If send instead a primarykey instead of whole documents like above. will the data can still be fetched at the frontend and also which one is better this method or the one above this?
If the server just sends the ID, the frontend will need to get the document information using that ID.
So in the frontend, there are two ways to get the detail information of the document using the ID.
The above two methods are all ineffective. Getting all the related data at once is much more effective and faster.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.