One way to do it is to run all operations, don't call "save" and verify "manually" if objects are correct. I don't know about other methods, but if someone else does it would be great.
On Sun, Mar 22, 2015 at 6:29 AM, Murthy Sandeep <sand...@sandeepmurthy.is> wrote: > Hi > > I have created an data migration script for populating one of > app db tables with data from a JSON file. First I ran > > python manage.py makemigrations --empty TPP_App > > > > (‘TPP_App’ is the name of my app) and then I added a custom > method called populate_db which will use bulk_create to add > multiple entries to the table, and then do a save() to write the > changes to the db. At the moment the custom method is empty > because I am still working on it, but the script looks like this right > now > > # -*- coding: utf-8 -*- > from __future__ import unicode_literals > > from django.db import models, migrations > > def populate_db( apps, schema_editor ): > print ‘Populating db from JSON file...' > > class Migration(migrations.Migration): > > dependencies = [ > ('TPP_App', '0003_auto_20150224_2024'), > ] > > operations = [ > migrations.RunPython( populate_db ), > ] > > How do I test this script to make sure the custom method works > as expected, before I run it fully? Can I call this from the interpreter > and test it with the db API? > > At the moment if I do > > python manage.py migrate > > it reports there are no migrations to apply. > > Sandeep > > > -- > 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/10767D81-937A-4F08-983A-B055C4AB3982%40sandeepmurthy.is > . > For more options, visit https://groups.google.com/d/optout. > -- *Filipe Ximenes*+55 (81) 8245-9204 *Vinta Software Studio*http://www.vinta.com.br -- 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/CAA-QWB34WORCeaYAYxSN6FewAKJ1xhzVZcJitQFiL7s9eBDS%3Dw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.