{
"_id": {
"$oid": "65ea05dbaa907e05219c0934"
},
"id": 6,
"title": "asd",
"content": "asd",
"author": "asd",
"category": "asd",
"createdAt": {
"$date": "2024-03-07T20:21:52.000Z"
}
}
I couldn’t find the answer to the question on the Internet and gpt
For posterity. The
_idfield is created by the MongoDB server and used by the server so you cannot delete that by default. It is 12 bit binary data.Nevertheless, this is not what the OP asked.
Djongo mimics Django’s ORM and so just like in Django, an
AutoField(AUTOINCREMENT field) is implicitly added to your models. This is theidfield you automatically get.But if you explicitly add an
ObjectIdField(internally setsprimary_keyasTrue), the implicitly createdAutoField(AUTOINCREMENT field) will not be added.Fun fact: using the
ObjectIdFieldin your models will save you from calling Django migrations every time you create a new model.