1

I have a running Django application running on webfaction server. I want to integrate my django project with a cloud storage system. How can I Integrate that ?

Here is the detail about my app: It is an erp software in django. It has a app named Projects. In that app, it has a model name Project.

  class Project(BaseModel):
        event = models.ForeignKey("events.Event")
        client = models.ForeignKey("clients.Client")
        project_supervisor = models.ForeignKey("staffs.Staff", blank=True, null=True)
        name = models.CharField(max_length=128)
        project_number = models.CharField(max_length=128, unique=True)
        currency = models.ForeignKey("projects.Currency")
        hall_number = models.CharField(max_length=128)
        stand_number = models.CharField(max_length=128)
        start_date = models.DateField()
        end_date = models.DateField()
        notes = models.TextField(blank=True, null=True)
        terms_and_conditions = models.TextField(blank=True, null=True)
        is_design_required = models.BooleanField(choices=BOOL_CHOICES, default=False)
        status = models.CharField(max_length=128, choices=PROJECT_STATUS, default="pending")
        admin_confirmed = models.BooleanField(default=False)
        is_quote_send = models.BooleanField(default=False)
        is_estimate_send = models.BooleanField(default=False)
        is_deleted = models.BooleanField(default=False)

I want add an extra field to this model to store the project details.And I want to upload these pictures in the cloud, say dropbox or google , and want to upload it through django.That means I want to store that document field only in a cloud database? Is that possible in DJANGO?

Nazir Ahmed
  • 615
  • 4
  • 14
  • 29
Niya Simon C
  • 279
  • 2
  • 4
  • 10

1 Answers1

2

To see the detail please see this stackoverflow Question
and the source code with APP v2 to upload file on dropbox is.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import dropbox

class TransferData:
    def __init__(self, access_token):
        self.access_token = access_token

    def upload_file(self, file_from, file_to):
        """upload a file to Dropbox using API v2
        """
        dbx = dropbox.Dropbox(self.access_token)

        with open(file_from, 'rb') as f:
            dbx.files_upload(f.read(), file_to)

def main():
    access_token = '******'
    transferData = TransferData(access_token)

    file_from = 'test.txt'
    file_to = '/test_dropbox/test.txt'  # The full path to upload the file to, including the file name

    # API v2
    transferData.upload_file(file_from, file_to)

if __name__ == '__main__':
    main()

The source code is hosted on GitHub code link and to get dropbox access token see this link

Nazir Ahmed
  • 615
  • 4
  • 14
  • 29
  • I'm asking about a specific field in a model to drop box.. Not the entire database.. All other fields are there in postgresql – Niya Simon C Nov 30 '17 at 07:26