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.
signature.asc
Description: Message signed with OpenPGP using GPGMail