Django - Cannot create migrations for ImageField with dynamic upload_to value

前端 未结 3 1019
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 04:34

I just upgraded my app to 1.7 (actually still trying).

This is what i had in models.py:

def path_and_rename(path):
    def wrapper(instance, filenam         


        
3条回答
  •  执念已碎
    2020-12-05 05:05

    I had the same problem but I have many ImageFile in my models

    head = ImageField(upload_to=upload_to("head")
    icon = ImageField(upload_to=upload_to("icon")
    ...etc
    

    I don't want create upload_to wraper func for every ImageField column I have.

    So I just create a func named wrapper, and it woks

    def wrapper():
        return
    

    I think it works just fine because I opened migration file and I found this:

    ('head', models.ImageField(upload_to=wrapper)),
    

    I guess it's not effect migration process

提交回复
热议问题