1π
β
It is possible using natural key, a custom manager and get_by_natural_key()
. Django doc has a full explanation, please read here. Iβd rather not copy paste everything here.
By using this method, you can turn the regular serialization like this β
{
"pk": 1,
"model": "store.book",
"fields": {
"name": "Mostly Harmless",
"author": 42
}
}
To this β
{
"pk": 1,
"model": "store.book",
"fields": {
"name": "Mostly Harmless",
"author": ["Douglas", "Adams"]
}
}
π€Bibhas Debnath
Source:stackexchange.com