This website collects cookies to deliver better user experience
Add document ID to the firestore document in Python
Add document ID to the firestore document in Python
Hi guys,
Today I want to share with you how to add the document ID to the firestore document before you push the data to firebase.
I think I can just skip the part where I explain you how to import firebase_admin to python, but I'll copy it anyways.
This is what you need to import ro make it work
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
Also you will need to set up your serviceAccountKey.json document. Find in the followig Link
She explains really nice how to set up firestore.
This part I really just copied it from that video and you can find it on firebase cred = credentials.Certificate("serviceAccountKey.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
Here is what's important, we need to reference the document that is being created.