Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
How to implement FirebaseDB with a Django Web Application

Am trying to implement Firebase Realtime Database with my Django Web Application. After properly setting up the configuration with Firebase, I got confused about how data will write into my Firebase Database from my Django website instead of using Sqlite, or Postgres.

Under settings.py, do I need to set my engine to Firebase? Am totally confused here. I do not want to use the normal ORM such as Sqlite, Postgres etc. I want my app to use Firebase.

Is there something else I need to understand about Firebase?

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

pyrebase_settings file

import pyrebase

config = {
    "apiKey": "my_api_key_is_here",
    "authDomain": "my_auth_domain_is_here",
    "databaseURL": "my_firebase_database_url_is_here",
    "projectId": "my_firebase_project_id_is_here",
    "storageBucket": "my_firebase_storageBucket_is_here",
    "serviceAccount": "my_serviceAccount.json_file_path_is_here",
    "messagingSenderId": "messagingSenderId_is_here"
}

# initialize app with config
firebase = pyrebase.initialize_app(config)

# authenticate a user
auth = firebase.auth()
user = auth.sign_in_with_email_and_password("email@usedforauthentication.com", "FstrongPasswordHere")


db = firebase.database()
about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

take a look at the database section of the doc. It details how you would interact with the database API. Typically you would use these in your views where you need to save or retrieve something from the database.

e.g say you want a view that gets users, you could have something like this:

#views.py
from pyrebase_settings import db, auth
from django.shortcuts import render

def get_users(request):
    users = db.child("users").get()
    return render(request, 'users.html', {'users': users.val()})

The documentation for retrieving data can be seen here

also say you want a view to save(signup) users, you could have something like so:

#views.py
from pyrebase_settings import db, auth

def signup(request):
   form = SignupForm(request.POST)
   if form.is_valid():
       email = form.cleaned_data('email')
       password = form.cleaned_data('password')
       auth.create_user_with_email_and_password(email, password)
   # the rest of your code goes here

the create_user_with_email_and_password method is documented here

PS. I have never made use of the pyrebase library so I write only based on what is specified in its docs. Also I am only writing these django snippets off the top of my head so forgive me if there are any syntax errors or typos :)

Hope this helps :)

about 4 years ago · Santiago Trujillo Denunciar

0

Is there something else I need to understand about Firebase?

No, there is something you need to understand about Django -- it is designed to use a relational database engine as its primary data store. Firebase is not relational.

Sorry to be the bearer of bad news.

Many answers on this question are missing this point, and suggesting code or libraries that let you access Firebase from Python. Sure, that's possible. But that doesn't make it work as a primary data store for Django. Django's ORM features and contrib apps all presume a relational database.

In order for this to work you'd need something along the lines of django-nonrel that supported Firebase. As far as I know that doesn't exist.

about 4 years ago · Santiago Trujillo Denunciar

0

consider having a look at the fcm-django library here https://github.com/xtrinch/fcm-django

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda