2016-04-03 5 views
1

Django 1.9アプリケーション(Python 2)を設定していますが、問題があります。Django 1.9アプリケーションの設定中にエラーをシリアル化できません

ValueError: Cannot serialize: [myapp.models.OverwriteStorage object at 0x7fa1b84fc150] There are some values Django cannot serialize into migration files. For more, see https://docs.djangoproject.com/en/1.9/topics/migrations/#migration-serializing

OverwriteStorageがジャンゴ/コア/ファイル/ storage.pyで発見Djangoの作り付けのストレージクラスを(上書きされます、私はmodels.pyに含まれたカスタムクラスである:私はpython manage.py makemigrationsをしようとすると、私は次のエラーを取得します)をAzure Storageで保存します。上記のリンク先に行くと、移行前にすべてのDjangoがシリアル化できないものの一覧が表示されます。

これを修正するにはどうすればよいですか?必要に応じて詳細情報をお尋ねください。

答えて

1

あなたのストレージクラスは分解不能でなければなりません。ポイント#4 in this checklist。ドキュメントから

def deconstruct(self): 
    path = 'python to your storage class' 
    args = {} 
    kwargs = {} 
    return path, args, kwargs 

引用:

Your storage class must be deconstructible so it can be serialized when it’s used on a field in a migration. As long as your field has arguments that are themselves serializable, you can use the django.utils.deconstruct.deconstructible class decorator for this (that’s what Django uses on FileSystemStorage).

+2

おかげでバディそれはあなたのカスタムストレージクラスにこのような

何かをdeconstruct()方法を提供する必要があり、を意味します。私は '' django.utils.deconstruct import deconstructible'からインポートした '@ deconstructable'クラスのデコレータを使って実際に終了しました –

+0

@HassanBaig – doniyor

関連する問題