CloudVault wird von der Cloudinary -Plattform erstellt. Vor der Installation des Pakets ist es großartig, ein Konto zu erstellen und die "API -Anmeldeinformationen" zu erhalten.
Klicken Sie hier, um ein Konto zu erstellen und dann Ihre Anmeldeinformationen auf Anmeldung zu erhalten.
Danach können Sie mit der cloudvault -Installation fortfahren.
pip install cloudvault
Sobald cloudvault installiert ist, gehen Sie zu den Einstellungen Ihres Projekts und fügen Sie die folgenden Zeilen hinzu
#!/usr/bin/python
# settings.py
INSTALLED_APPS = [
# ... other apps
"cloudvault" # can be omitted
]
CLOUDINARY = {
"cloud_name": "your_cloud_name",
"api_key": "your_api_key",
"api_secret": "your_api_secret"
}
DEFAULT_FILE_STORAGE = "cloudvault.cloud_storage.CloudinaryStorage"
Bei der Verwendung von cloudvault in Ihrem Projekt ändert sich nichts.
#!/usr/bin/python
# models.py
class Picture(models.Model):
image = models.ImageField()
def __str__(self);
return str(self.id)
Wenn eine Picture gespeichert wird, speichert es es auf wolkinäres self.image.url gibt eine URL zurück, die auf das Bild auf cloudinary zeigt
Um das Projekt zu installieren, klonen Sie einfach das Projekt in Ihr System und laufen Sie dann aus
python -m pip install /path/to/project/cloudvault/cloudvault/dist/cloudvault-1.1.tar.gz
Das Projekt sollte erfolgreich installiert werden.
Gabriel Michael Ojomakpene
[email protected]
09020617734