Skip to content Skip to sidebar Skip to footer

Valueerror: Cannot Serialize:

I am trying to use AzureStorage to for connecting azure storage with django 1.7 app . models.py from django.db import models from myproject.storage import AzureStorage class MyMo

Solution 1:

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:

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:

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.

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.

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

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 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.

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.

Post a Comment for "Valueerror: Cannot Serialize: "