ValueError错误:无法序列:其中,myproject.storage.AzureStorage对象在0x7f85185e66d0> [英] ValueError: Cannot serialize: <myproject.storage.AzureStorage object at 0x7f85185e66d0>

查看:253
本文介绍了ValueError错误:无法序列:其中,myproject.storage.AzureStorage对象在0x7f85185e66d0>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 AzureStorage 用于连接Azure存储使用Django 1.7应用程序。

I am trying to use AzureStorage to for connecting azure storage with django 1.7 app .

models.py

models.py

from django.db import models
from myproject.storage import AzureStorage

class MyModel(models.Model):
    my_file = models.FileField(upload_to="files", storage=AzureStorage(container="media"))
    my_image = models.ImageField(upload_to="images", storage=AzureStorage(container="media"))

但是,当我尝试makemigrations我越来越:

But when I try to makemigrations I am getting :

ValueError: Cannot serialize: <myproject.storage.AzureStorage object at 0x7f85185e66d0>
There are some values Django cannot serialize into migration files.
For more, see https://docs.djangoproject.com/en/dev/topics/migrations/#migration-serializing

究竟它无法序列化?

What exactly its not able to serialize ?

推荐答案

你检查从<一个​​解决方案href=\"http://stackoverflow.com/questions/25648335/upgrading-to-django-1-7-getting-error-cannot-serialize-storages-backends-s3b\">Upgrading到Django的1.7。收到错误:无法序列:其中,这是一个类似的问题询问之前storages.backends.s3boto.S3BotoStorage对象。这里复制的回答您的快速参考:

Have you checked the solution from Upgrading to Django 1.7. Getting error: Cannot serialize: <storages.backends.s3boto.S3BotoStorage object which was a similar question asking before. Copied the answer here for your quick reference:

这里的基本问题是,你要使用的Django 1.7与
  包(Django的货仓)不似乎已被更新,以
  与该版本尚未工作。

The basic issue here is that you are trying to use Django 1.7 with a package (django-storages) that doesn't appear to have been updated to work with that version yet.

下面是从文档的一些摘录解释什么是
  发生的事情:

Here are some excerpts from the documentation to explain what is happening:

迁移是包含的旧的定义只是Python文件
  你的模型 - 于是,他们写的Django必须采取的当前状态
  你的模型和序列化出来到一个文件中。

Migrations are just Python files containing the old definitions of your models - thus, to write them, Django must take the current state of your models and serialize them out into a file.

虽然Django的可以序列化的大多数事情,还有一些事情,我们
  只是不能序列化出到一个有效的Python重新presentation - 有
  如何值没有Python标准可以变回code。

While Django can serialize most things, there are some things that we just can’t serialize out into a valid Python representation - there’s no Python standard for how a value can be turned back into code.

您可以让Django的通过给连载自己的自定义类实例
  A类解构()方法。

You can let Django serialize your own custom class instances by giving the class a deconstruct() method.

所以这里的解决方案是给类
  storages.backends.s3boto.S3BotoStorage一个解构()方法。那
  可能是因为应用@deconstructible类一样简单
  装饰。

So the solution here is to give the class storages.backends.s3boto.S3BotoStorage a deconstruct() method. That will probably be as easy as applying the @deconstructible class decorator.

presumably包将包含在某些时候这种变化(或
  也许是主分支已经有了吗?),但你也可以只
  自己修补它。

Presumably the package will incorporate this change at some point (or perhaps the master branch already has it?), but you could also just patch it yourself.

请随时让我们知道,如果解决方案(使用@deconstructible类装饰从django.utils.deconstruct添加的解构()方法)不为你工作。

Please feel free to let us know if the solution (use the @deconstructible class decorator from django.utils.deconstruct to add the deconstruct() method) does not work for you.

这篇关于ValueError错误:无法序列:其中,myproject.storage.AzureStorage对象在0x7f85185e66d0&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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