Python 如何将django项目集成到云存储
我有一个正在运行的Python 如何将django项目集成到云存储,python,django,cloud,webfaction,Python,Django,Cloud,Webfaction,我有一个正在运行的Django应用程序运行在webpartion服务器上。我想将django项目与云存储系统集成。我该如何整合这一点 以下是有关我的应用程序的详细信息: 它是django中的erp软件。它有一个名为Projects的应用程序。在该应用程序中,它有一个模型名称项目 class Project(BaseModel): event = models.ForeignKey("events.Event") client = models.ForeignK
Django应用程序
运行在webpartion服务器上
。我想将django项目与云存储系统集成。我该如何整合这一点
以下是有关我的应用程序的详细信息:
它是django中的erp软件。它有一个名为Projects
的应用程序。在该应用程序中,它有一个模型
名称项目
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)
我想在这个模型中添加一个额外的字段来存储项目详细信息。我想在云中上传这些图片,比如dropbox或google,并想通过django上传。这意味着我只想在云数据库中存储该文档字段?这在DJANGO中可能吗?要查看详细信息,请参阅此stackoverflow
和源代码与应用v2上传文件的dropbox是
#!/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()
源代码托管在GitHub上,要获取dropbox访问令牌,请参见此我想了解dropbox模型中的特定字段。。不是整个数据库。。所有其他字段都在postgresql中