I've made a mistake of creating my own User model and am trying to recover.
I've created a south migration that copies my old user models and creates django.contrib.auth.models.User models. To ensure my current users don't get left in the dark, I created a bunch of unittests to ensure everything gets converted appropriately.
So, I need to test the south migration and see if it worked. In order to do that I need to load data of the old User type before the migration runs. How do I do that?
When the test suite is run via python manage.py test someapp
, first django creates a test database, then applies all migrations in order, then runs test cases. So if the goal is to test the migration itself, you'll need to load fixture data before that migration.
You can add a line or two loading fixture to your migration that applies your model changes just for the sake of testing, then remove.
def forwards(self, orm):
from django.core import management
management.call_command('loaddata', 'myfixture.json')
... your migration
also, you can add a condition on some made up django setting, then you won't have to edit the code later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With