After adding the new model and doing the migration you have to write a small script which will convert the data. You have to go through all the Reactionsmeta objects with
for reaction in Reactionsmeta.objects.all(): Then within the for loop you have to create another for loop which will go through all metabolite columns from 1 to 6: for i in range(1, 7): Then you would have to check if the column is not None: current_metabolite = getattr(reaction, 'metabolite' + i, None) current_stoichiometry = getattr(reaction, 'stoichimetry' + i, None) if current_metabolite is not None and current_stoichiomentry is not None: If current_metabolite is not none you can add a new StoichiometryMetabolite object: StoichiometryMetabolite.objects.create(metabolite=current_metabolite, stoichiometry=current_stoichiomentry, reaction=reaction) That' basically it. You should probably also write a test which makes sure that all data has successfully converted. If everything worked fine and all views, templates etc have been updated you can remove the old fields from the model. -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8bc232f8-7a86-4c41-8c08-ed0d8e4363fa%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.