Neel Sharma
Neel Sharma

Reputation: 53

Django Firebase

I am trying to connect my Django website with Firebase. There is not enough material for that, luckily I got this https://github.com/thisbejim/Pyrebase but I am not able to understand where to write this code.

I have written this code in pyrebase.py file:

import pyrebase

config = {
    apiKey: "AIzaSyD0kwTsifJAL3C7mTj6Hil6Lfutes0jdEo",
    authDomain: "minor1-5e62c.firebaseapp.com",
    databaseURL: "https://minor1-5e62c.firebaseio.com",
    projectId: "minor1-5e62c",
    storageBucket: "minor1-5e62c.appspot.com",
    messagingSenderId: "69802125895"
  };
firebase=firebase.initializeApp(config);

and when I am running it on python terminal I am getting this error:

Traceback (most recent call last): File "D:\Django2\mysite1\personal\dd.py", line 4, in apiKey: "AIzaSyD0kwTsifJAL3C7mTj6Hil6Lfutes0jdEo", NameError: name 'apiKey' is not defined

How can I fix this?

Upvotes: 1

Views: 748

Answers (1)

Chris
Chris

Reputation: 137075

Python dicts use immutable values (like strings) as keys.

Try something like this instead:

import pyrebase

config = {
    'apiKey': '...',
    'authDomain': '...',
    'databaseURL': '...',
    'projectId': '...',
    'storageBucket': '...',
    'messagingSenderId': '...',
}

firebase = firebase.initializeApp(config)

Note also that semicolons usually aren't used with Python, though they are legal.

Upvotes: 2

Related Questions