How to create a new project in Django using Firebase Database?
Django is a Python-based web framework that allows you to quickly create efficient web applications. If you are new to Django then you can refer to Django Introduction and Installation. Here we are going to learn How to create a Django project using Firebase as Database .
How to create a new project in Firebase ?
Step 1: Firstly, We are going to Create a project on Firebase to connect our static web page. Visit Firebase Page For Configuring Your Project – https://console.firebase.google.com/u/0/?pli=1
Click On Add Project Button.
Step 2: Give a Name To your Project and Click On Continue Button.
Step 3: Now Click On Continue Button.
Step 4: Now Choose Default Account For Firebase and Click On Create Project.
Step 5: Now Your Project is created. You are Good to Go. Click on Continue .
Step 6: Now Click On 3rd icon that’s Web Button(</>).
Step 7: Give a nickname to your Web Project and Click On Register App
Step 8: Now you will see the configuration of your App like this. Copy this Code somewhere .You wlll need it later.
Step 9 : Click On The Realtime Database button As Shown In Figure.
Step 10: Now Click On Create Database.
Step 11: Now Click On Test Mode and then Click On Enable.
Now, We will Add Some Data and will try to Retrieve that using our Website
Integrating Firebase Database to Django Project –
Now, I hope that you have already create a project in Django. If not then Refer to How to Create a Basic Project using MVT in Django ? Since we are using firebase as Database , We need to install pyrebase . For this Type the following Command in terminal
$pip install pyrebase4
Create a views.py file in your project directly. The Structure should be like this .
Now move to your project directory and run our project using the given command :
python manage.py runserver
Project Output will be as Follow –
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course