Easiest way to rename a model using Django/South?

To answer your first question, the simple model/table rename is pretty straightforward. Run the command: ./manage.py schemamigration yourapp rename_foo_to_bar –empty (Update 2: try –auto instead of –empty to avoid the warning below. Thanks to @KFB for the tip.) If you’re using an older version of south, you’ll need startmigration instead of schemamigration. Then manually edit … Read more

What’s the recommended approach to resetting migration history using Django South?

If you need to selectively (for just one app) reset migrations that are taking too long, this worked for me. rm <app-dir>/migrations/* python manage.py schemamigration <app-name> –initial python manage.py migrate <app-name> 0001 –fake –delete-ghost-migrations Don’t forget to manually restore any dependencies on other apps by adding lines like depends_on = ((“<other_app_name>”, “0001_initial”),(“<yet_another_app_name>”, “0001_initial”)) to your … Read more

Django – How to rename a model field using South?

You can use the db.rename_column function. class Migration: def forwards(self, orm): # Rename ‘name’ field to ‘full_name’ db.rename_column(‘app_foo’, ‘name’, ‘full_name’) def backwards(self, orm): # Rename ‘full_name’ field to ‘name’ db.rename_column(‘app_foo’, ‘full_name’, ‘name’) The first argument of db.rename_column is the table name, so it’s important to remember how Django creates table names: Django automatically derives the … Read more

Backwards migration with Django South

You need to figure out the number of the migration just before the one you want to roll back. Your app should have a migrations directory, with files in it named like 0000_initial.py 0001_added_some_fields.py 0002_added_some_more_fields.py 0003_deleted_some_stuff.py Normally, when you run ./manage.py migrate your_app, South runs all new migrations, in order. (It looks at the database … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)