Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django south migration with --noinput does not remove contenttypes when renaming tables

I am using django-south for migrating database tables in a django project. And I am renaming a model as discussed in a previous question:

    # Renaming model from 'Foo' to 'Bar'                                                                                                                      
    db.rename_table('myapp_foo', 'myapp_bar')                                                                                                                        
    db.send_create_signal('myapp', ['Bar'])

However, I use fabric to automatically deploy my application to production servers, and I want the migrations to run without any user input. For this, I run the migration command with the noinput option as follows

python manage.py migrate --noinput

This works fine except that the send_create_signal does not remove stale contenttypes in this mode.

This is because the django contenttype managament command update_contenttypes only removes the stale contenttypes if input is given.

I could replicate the update_contenttypes command directly in the south migration, but that does not seem like a good solution. Does anyone have suggestions on how to trigger the removal of the contenttypes without repeating what is in the django command?

like image 737
yellowcap Avatar asked Nov 11 '22 17:11

yellowcap


1 Answers

In my experience, running manage.py syncdb --all works some, but not all of the time when South is involved. You might try giving it a go, as it has worked for me in the past, certainly when removing stale models from the content-types table.

like image 174
Steadman Avatar answered Nov 15 '22 07:11

Steadman