Hi Micky,
When I had to migrate FK->M2M, I found that hand-hacking a migration file was 
the way to go. I wrote a multiple operation migration class that did the 
following:

1. create a M2M, nullable field, and set all defaults to null
2. use RunPython to run a function which takes the data from the FK field, and 
connects the objects in the M2M relation (bonus: create a function that does 
the opposite, to make this script totally reversible!)
3. remove the FK field
4. make the M2M field non-null (if desirable)

If you want the fields to be the same name, I think the safest bet is to 
prepend a step to the list above:

0. change name on FK field to temporary name

But I can't remember why I think that's better than changing the M2M field at 
the end.

I would share the code, but I can't find it at the moment. Sorry about that.

Hope that's helpful,
Andrew

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11CFD73D-4B02-4B36-AE3C-7A5567D3C2A0%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to