Skip to main content

An Unofficial Django and Firebase Library

Project description

An Unofficial Django and Firebase Library

This library aims to enable the uploading of media directly to Firebase from Django forms.

The FirebaseFileField provides four main automatic functionalities, which are:

  • Saving the file to Firebase: If a file with the same name already exists, it will be renamed and saved. If you update the file, the previous one will be deleted.
  • Moving the file: If you change the upload_to field and update a post of this model, the file will be automatically moved to the new address specified in upload_to.
  • Checking if the file still exists: If you update a post and the file has been manually deleted from Firebase, the link in the post will be updated to None.
  • Deleting the file: If you select to empty the field, the file will be automatically deleted.

How to use:

  • First, you need to have the Firebase key file. It can be added to the root directory or another path of your choice and added to the settings, but it must be renamed to Key.json.

      FIREBASEKEYPATH = "example/example"
    
  • Second, you need to add the Firebase storage bucket to the settings.

    STORAGEBUCKET = {'storageBucket': 'example.appspot.com'}
    
  • Now, you just need to import and use it.

    from firebasefilefield.import FirebaseFileField
    
    class ExampleModel(models.Model):
        Example = FirebaseFileField(upload_to='uploads/', null=True, blank=True)
    

If you don't want files to be automatically deleted along with the post, just set auto_delete to False.

  from firebasefilefield.import FirebaseFileField
  
  class ExampleModel(models.Model):
      Example = FirebaseFileField(upload_to='uploads/', null=True, blank=True, auto_delete=False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_firebase_filefield-2.0.0.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file django_firebase_filefield-2.0.0.tar.gz.

File metadata

File hashes

Hashes for django_firebase_filefield-2.0.0.tar.gz
Algorithm Hash digest
SHA256 7a69e237ec533a1f3dc9dac551d34345e05ffcc1f2ab2800b5c0c5f1763dbaf0
MD5 fa00664d38864a5c3c631224672e8815
BLAKE2b-256 3399433ad5ee76e98a3945b54b9e7b26900ed3fd5dbbf3ab6f586c310d2ca377

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page