Skip to main content

Python Django with Google Firebase : Getting Started, Intro, Basic Configuration & Firebase Authentication #Part1

Looking for an easy way to add a database to your Python Web App? We’ll show you how to get started with Firebase integration in Django. Creating an app isn’t easy, but learning how to store your app’s vital data is! Here is a step-by-step tutorial to help you figure out how to connect to a Python Django WebApp with Firebase and take the headache out of user authentication, data storage and retrieval. A Python app without Firebase is like a chicken without a hen-house; if you don’t have a place to store your eggs, it’s time to re-think the farm.
In this beginners tutorials we'll work on Connecting Firebase with Django and creating a Simple SignIn form to showcase the example of Firebase authentication.

Check out this video, code below follows the video to help

If you like videos like this consider donating $1, or simply turn off AdBlocker. Either helps me to continue making tutorials.

Transcript / Cheat Sheet

1. Configure FIREBASE 

Open your Firebase Console

Create new project by Selecting Add Project.

Navigate to Authentication on Dashboard and set SIGN-IN method Email/Password to enable.

For first time add a manual user.

Now, navigate to Project Overview and select Add Firebase to WebApp now, copy config's for later use in Django.

Now Let's Get started for integrating Firebase with Python Django .

2. Installing Required Libraries

Installing pip

Before we can connect to our Firebase database with Python, we need to download a couple of helper modules. We are going to use pip to install them.
You can check to see if you currently have pip install by running the command in the terminal:

pip3 --version
If it is not currently installed, you can install pip by running following command:
sudo apt-get -y install python3-pip && sudo apt-get update

 Installing Pyrebase

Pyrebase is a Python interface to Firebase’s REST API. In layman’s terms, it allows you to use Python to manipulate your Firebase database. The documentation for Pyrebase can be found at

We will install the Pyrebase and its dependencies using pip:
sudo pip3 install Pyrebase

 Installing Django 

sudo pip3 install django

3. Working with Django

Creating new Django Project :

# sudo django-admin startproject cpanel 

# cd cpanel

# python3 runserver
//Open browser & type :
//Output : IT'S WORKED
//now make migrations:
# python3 migrate
// create a directory named templates
# mkdir templates
// go to cpanel directory and create file
# cd cpanel
# touch 
// go to file and configure the templates directory over there
// go to line 57 and edit it:
        'DIRS': ['templates'],

Code for :

import pyrebase from django.shortcuts import render
config = {
'apiKey': "AIzaS--your config here ---fOMd4pYUkbkZVvI",
'authDomain': "",
'databaseURL': "",
'projectId': "cpanel-5e873",
'storageBucket': "",
'messagingSenderId': "579985583952"
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
def singIn(request):
return render(request, "signIn.html")
def postsign(request):
passw = request.POST.get("pass")
user = auth.sign_in_with_email_and_password(email,passw)
message = "invalid cerediantials"
return render(request,"signIn.html",{"msg":message})
return render(request, "welcome.html",{"e":email})

Code for :

from django.contrib import admin
from django.conf.urls import url
from . import views
urlpatterns = [

Code for Html Templates :


{% if msg %}
{% endif %}
<html lang="en">
<meta charset="UTF-8">
<form action="/postsign/" method="post">
{% csrf_token %}
Email :
<input type="email" name="email">
<input type="password" name="pass">
<input type="submit" value="SignIn">


<html lang="en">
<meta charset="UTF-8">
{% csrf_token %}
Welcome {{e}}

That's end up with great on Tutorial on Python Django with Firebase : Getting Started and Firebase Authentication, I hope you guys enjoyed it :)

Get full source code for Django Project Here.


  1. startproject starts pycharm or visual studio IDE rather than creating project. Help me please

  2. what about hosting django projects on firebase?
    Because the firebase cli redirects everything to the public folder which firebase serves..
    I was looking for some tutorial about it and found nothing !!

    1. sorry to say, but you can't host django on firebase hosting. For that you can use google cloud console check out this blog :

  3. How to save a user on the db?

  4. oh my very useful and easy article , thanks a ton

  5. Make money on kasino online and do not regret anything gamble casino with us Make money on kaino online and do not regret anything.

  6. Thanks for documenting Django-Pyrebase-firebase

  7. i got an error it says] {
    "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key.",
    "errors": [
    "message": "API key not valid. Please pass a valid API key.",
    "domain": "global",
    "reason": "badRequest"
    "status": "INVALID_ARGUMENT"

    please help

  8. def postsign(request):
    email = request.POST.get('email')
    passw = request.POST.get("pass")
    message = "Login succesfull"

    Se debe definir message antes de el except

  9. Al-Zahra area, which is one of the largest regions in the State of Kuwait, and we at Kuwait فني تكييف company are happy to offer repair services for Al-Zahraa Air Conditioning to all of our customers in this region


  10. فني تكييف الكويت تقدم لكم جميع خدمات فني تكييف ٢٤ ساعه و تصليح مكيفات و فني تكييف مركزي هندي
    ، صيانة تكييف مركزي و تصليح تكييف مركزي و تصليح وحدات تكييف
    تركيب تكييف و كمبروسرات جديد و مستامل جميع مناطق بالكويت فني تكييف


Post a comment

If you have any doubts please comment !