Easiest way to rename a model using Django/South?

后端 未结 4 1800
無奈伤痛
無奈伤痛 2020-11-29 15:44

I\'ve been hunting for an answer to this on South\'s site, Google, and SO, but couldn\'t find a simple way to do this.

I want to rename a Django model using South.

4条回答
  •  暖寄归人
    2020-11-29 15:59

    South can't do it itself - how does it know that Bar represents what Foo used to? This is the sort of thing I'd write a custom migration for. You can change your ForeignKey in code as you've done above, and then it's just a case of renaming the appropriate fields and tables, which you can do any way you want.

    Finally, do you really need to do this? I've yet to need to rename models - model names are just an implementation detail - particularly given the availability of the verbose_name Meta option.

提交回复
热议问题