我想尝试django-dropbox
将图片直接上传到Dropbox。
这是模型
from django_dropbox.storage import DropboxStorage
STORAGE = DropboxStorage()
class Drop(models.Model):
photo = models.ImageField(upload_to='photos', storage=STORAGE,null=True, blank=True)
resume = models.FileField(upload_to='resumes', storage=STORAGE,null=True, blank=True)
但是当我尝试迁移时,我得到了这个错误:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemigrations.py", line 124, in handle
self.write_migration_files(changes)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemigrations.py", line 152, in write_migration_files
migration_string = writer.as_string()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/writer.py", line 131, in as_string
operation_string, operation_imports = OperationWriter(operation).serialize()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/writer.py", line 82, in serialize
arg_string, arg_imports = MigrationWriter.serialize(item)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/writer.py", line 263, in serialize
item_string, item_imports = cls.serialize(item)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/writer.py", line 333, in serialize
return cls.serialize_deconstructed(path, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/writer.py", line 239, in serialize_deconstructed
arg_string, arg_imports = cls.serialize(arg)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/writer.py", line 409, in serialize
"topics/migrations/#migration-serializing" % value
ValueError: Cannot serialize: <django_dropbox.storage.DropboxStorage object at 0xa01db4c>