升级到Django 1.7。获取错误:无法序列化:< storages.backends.s3boto.S3BotoStorage对象 [英] Upgrading to Django 1.7. Getting error: Cannot serialize: <storages.backends.s3boto.S3BotoStorage object

查看:455
本文介绍了升级到Django 1.7。获取错误:无法序列化:< storages.backends.s3boto.S3BotoStorage对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将django应用程序从django 1.6.6升级到1.7,并使用python 2.7.8。当我运行 python manage.py makemigrations 时,我收到以下错误:

I am trying to upgrade a django app from django 1.6.6 to 1.7 and am using python 2.7.8. When I run python manage.py makemigrations, I get the following error:

ValueError: Cannot serialize: <storages.backends.s3boto.S3BotoStorage object at 0x11116eed0>
There are some values Django cannot serialize into migration files.

这里是相关代码:

protected_storage = storages.backends.s3boto.S3BotoStorage(
      acl='private',
      querystring_auth=True,
      querystring_expire=3600,
    )


    class Document(models.Model):
        ...
        file = models.FileField(upload_to='media/docs/', max_length=10000, storage=protected_storage)

        def __unicode__(self):
            return "%s" % self.candidate

        def get_absolute_url(self):
            return reverse('documents', args=[str(self.pk)])

阅读迁移文档,并阅读有关类似问题的此处,但我一直无法解决这个问题我的应用程序使用django-storages和boto将文件保存到Amazon S3上。任何帮助都不胜感激。

I've read the migration docs and read about a similar issue here, but I've been unable to resolve this. My app uses django-storages and boto to save files onto Amazon S3. Any help is appreciated.

推荐答案

只需制作一个解构方法,然后使用它。

Just make a deconstructible subclass and use it instead.

from django.utils.deconstruct import deconstructible


@deconstructible
class MyS3BotoStorage(S3BotoStorage):
    pass

这篇关于升级到Django 1.7。获取错误:无法序列化:&lt; storages.backends.s3boto.S3BotoStorage对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆