foreign keys - Django migration error :you cannot alter to or from M2M fields, or add or remove through= on M2M fields -
i'm trying modify m2m field foreignkey field. command validate shows me no issues , when run syncdb :
valueerror: cannot alter field xxx yyy not compatible types (you cannot alter or m2m fields, or add together or remove through= on m2m fields)
so can't create migration.
class institutestaff(person): user = models.onetoonefield(user, blank=true, null=true) investigation_area = models.manytomanyfield(investigationarea, blank=true,) investigation_group = models.manytomanyfield(investigationgroup, blank=true) council_group = models.foreignkey(councilgroup, null=true, blank=true) #profiles = models.manytomanyfield(profiles, null = true, blank = true) profiles = models.foreignkey(profiles, null = true, blank = true)
this first django project suggestions welcome.
potential workarounds:
create new field foreignkey relationship called profiles1
, not modify profiles
. create , run migration. might need related_name
parameter prevent conflicts. subsequent migration drops original field. migration renames profiles1
profiles
. obviously, won't have info in new foreignkey field.
write custom migration: https://docs.djangoproject.com/en/1.7/ref/migration-operations/
you might want utilize makemigration
, migration
rather syncdb
.
does institutestaff
have info want retain?
django foreign-keys migration manytomanyfield
No comments:
Post a Comment