Question

I am working on building a ecomerse site with digital downloads to do this I need to add a field to the product model I know that mezzanine allows for injection of aditional fields but when I run schemamigration it adds the first field then hangs and dosen't add the other field does anyone have any ideas as to why this might happen here is my extra models section bellow.

EXTRA_MODEL_FIELDS = (
    (
        "cartridge.shop.models.Order.callback_uuid",
        "django.db.models.CharField",
        (),
        {"blank" : False, "max_length" : 36, "default": ""},
    ),
    (
        "cartridge.shop.models.Product.download_file",
        "django.db.models.FileField",
        (),
        { "blank" : True, "upload_to" : "downloads", },
    ),
)

So just to be clear the command I am running is python manage.py schemamigration cartridge.shop --auto --stdout > content/migrations/0001_cartridge_shop_add_download_file.py

it says the field callback_uuid is added but this already exists so it is fine then it hangs and doesn't add download_file.

any help would be appreciated.

Was it helpful?

Solution

The answer to this question is to add a default to the atributes it won't work with a none type but if you pass it a empty string it then works fine.

EXTRA_MODEL_FIELDS = (
    (
        "cartridge.shop.models.Order.callback_uuid",
        "django.db.models.CharField",
        (),
        {"blank" : False, "max_length" : 36, "default": ""},
    ),
    (
        "cartridge.shop.models.Product.download_file",
        "django.db.models.FileField",
        (),
        { "blank" : True, "default" : "" , "upload_to" : "downloads", },
    ),
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top