I have a Firebase Firestore database connected to a Flutter mobile application. I want to build a web application to manage the users' data and handle new users. I have decided to use Django for my web application, but I have two questions if anyone can help.
First, is it actually reliable to use Django as the framework for this purpose? Second, I was trying to make a connection between Django and my existing DB to just try to call some values but I was getting this error:
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application.
Here is the code I am using for the connection
db = firestore.Client()
config={
"apiKey": "******************",
"authDomain": "*******.firebaseapp.com",
"projectId": "*******",
"storageBucket": "*******.appspot.com",
"messagingSenderId": "*******",
"appId": "******************",
"databaseURL": "https://***********.firebaseio.com",
}
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
database = firebase.database()
def index(request):
doc = db.collection('test').document('test1').stream()
weight= doc['weight']
return render(request, 'index.html', {
"weight":weight,
})
CodePudding user response:
You're initializing Pyrebase with client-side configuration data. But Pyrebase doesn't have any built-in support for Firestore, so most likely you'e importing that from elsewhere. If your firestore
comes from the Admin SDK that Firebase itself supports for use in Python code, you'll need to initialize that SDK too, as shown here in the documentation on setting up Firebase on your server