django - How to convert many to many field to foreign key? -
lets have model class like;
class samplingquery(models.model): brands = models.manytomanyfield(brand)
after while realize need convert manytomanyfield foreignkey need convert class foreignkey;
class samplingquery(models.model): brands = models.foreignkey(brand)
is there way without losing data?
thank you
there no simple mechanism, can following:
create new
foreignkey
(say,brand
)copy existing data
brands
(by slicing first result since there can multiplemanytomany
relation)brand
delete field
brands
Comments
Post a Comment