A Firebase-django integration package where your files are uploaded to Firebase and the rest of the work is done by the package.
Project description
EasyFirebase
An easy implementation of Firebase in django application. If you do not want to upload your static files (ex: Image, pdf etc.) to the server then you can use easyfirebase to upload all of your static files to Firebase and easyfirebase will do the rest. Updating your file on updating models, deletions of file while you delete your model object or changes the file etc.
Usage
from easyfirebase.fields import FirebaseImageField
from easyfirebase.storage import FirebaseStorage
class MyModel(models.Model):
name = models.CharField(max_length=100)
#...
photo = models.FirebaseImageField(storage=FirebaseStorage, ... )
If you do not provide any parameter for storage, then easyfirebase will use Default Django storage, which will store your image/pdf files in the local/server root dir or upload dir provided by STATIC_ROOT.
Installation
pip install easyfirebase
Or,
Download the tar file and run the following command in django environment.
pip install ./easyfirebase.tar.gz
add the app name in the settings.py
of project.
INSTALLED_APPS = [
...
'easyfirebase',
...
]
Configure Settings.py
Get your firebase json config file and info from firebase console. Write the following code in your projects settings.py
file:
FIREBASE_CONFIG = {
"apiKey": "your api key",
"authDomain": "your domain name",
"databaseURL": "your databaseURL",
"projectId": "your projectID",
"storageBucket": "your storageBucket",
"messagingSenderId": "your messagingSenderId",
"appId": "your app id",
"measurementId": "your measurementId",
}
FIREBASE_CREDENTIALS_FILE = (
BASE_DIR / "path/to/your/firebase/config/file.json"
)
[optional: settings.py
]
FIREBASE_DEFAULT_UPLOAD_DIR = "test_dir"
This will set the default upload directory for all FirebaseImageField instances in the Firebase Storage. If not provided, easyfirebase will first try to set the Project_name
as the default upload dir in the Firebase Storage.
or if the above also fails, FreeDjangoFirebase/
will be the default upload dir.
Note: You must put your FIREBASE_CONFIG in settings.py
and put your firebase sdk json file in the BASE_DIR
of the project. ie, in the directory where settings.py
resides.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file easyfirebase-2.0.0.tar.gz
.
File metadata
- Download URL: easyfirebase-2.0.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 484ef8524d37f055d562017657a1c5db5653a70cbce3825796bca685c9c3c923 |
|
MD5 | 9a73839c38acc31916287c1ecbf3499d |
|
BLAKE2b-256 | 7ff0ec3f7ed5f9dbff2432fca3d8cd2de0867e3623d7421a811ad09e5b3a2e01 |
File details
Details for the file easyfirebase-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: easyfirebase-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01ba48d22cb924095c247262ecc9247a42db0ccc337294d20387097ea7fe77ad |
|
MD5 | ca4bbb16bc9d3e6055d266e4d5e9a116 |
|
BLAKE2b-256 | 632047f878af7ffb8d840019ddbfead8a80a7066a173369d46b2234d3f654806 |