Error with the south when testing blocks using the nose

I'm having difficulty getting my Django tests to work properly; I use the nose, and I began to receive an error message when applying migrations, as from table 1 the relation of the foreign key to table 2 did not succeed with the error:

django.db.utils.DatabaseError: relation "table2_column" does not exist 

After seeing how the migrations were applied, it was clear to me that table1 was not created before the foreign key relationship was applied, so I tried to figure out how to force the dependency and found the following article: http://south.aeracode.org/docs /dependencies.html

Then I added:

 depends_on = ( ("app2", "0001_inital"), ) 

to the app1 / 0001_initial.py file.

Unfortunately, now I get the following error:

 south.exceptions.DependsOnUnknownMigrationMigration 'app1:0001_initial' depends on unknown migration 'app2:0001_inital'. 

Any ideas on how to solve this?

+6
django migration django-south nose
source share
3 answers

You have a typo in the name of migration, depending on this. It should be:

 depends_on = ( ("app2", "0001_initial"), ) 

This dependency system worked for me, having exactly the same problem you list here, and then finding South docs dependency systems.

+5
source share

I'm not sure if this will solve your problem, but you can add a parameter to use syncdb instead of migrating when running tests. Add the following line to your settings.py

 SOUTH_TESTS_MIGRATE = False 
+19
source share

This error also occurs if an error occurs during the import of the target module: if you have manual migrations and you are sure that the file name matches your depend_on or needed_by , check the error correction file.

In addition, setting SOUTH_TESTS_MIGRATE to False will not solve the problem. It just means that you will not see the problem until you try to use migration.

http://south.readthedocs.org/en/latest/settings.html

(This is still useful if you want to speed up your unittests.)

0
source share

All Articles