Migration for creating and deleting model in South
- by Almad
I've created a model and created initial migration for it:
db.create_table('tvguide_tvguide', (
('id', models.AutoField(primary_key=True)),
('date', models.DateField(_('Date'), auto_now=True, db_index=True)),
))
db.send_create_signal('tvguide', ['TVGuide'])
models = {
'tvguide.tvguide': {
'channels': ('models.ManyToManyField', ["orm['tvguide.Channel']"], {'through': "'ChannelInTVGuide'"}),
'date': ('models.DateField', ["_('Date')"], {'auto_now': 'True', 'db_index': 'True'}),
'id': ('models.AutoField', [], {'primary_key': 'True'})
}
}
complete_apps = ['tvguide']
Now, I'd like to drop it:
db.drop_table('tvguide_tvguide')
However, I have also deleted corresponding model. South (at least 0.6.2) is however trying to access it:
(venv)[almad@eva-03 project]$ ./manage.py migrate tvguide
Running migrations for tvguide:
- Migrating forwards to 0002_removemodels.
> tvguide: 0001_initial
Traceback (most recent call last):
File "./manage.py", line 27, in <module>
execute_from_command_line()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/management/commands/migrate.py", line 91, in handle
skip = skip,
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/migration.py", line 581, in migrate_app
result = run_forwards(mapp, [mname], fake=fake, db_dry_run=db_dry_run, verbosity=verbosity)
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/migration.py", line 388, in run_forwards
verbosity = verbosity,
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/migration.py", line 287, in run_migrations
orm = klass.orm
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 62, in __get__
self.orm = FakeORM(*self._args)
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 45, in FakeORM
_orm_cache[args] = _FakeORM(*args)
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 106, in __init__
self.models[name] = self.make_model(app_name, model_name, data)
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 307, in make_model
tuple(map(ask_for_it_by_name, bases)),
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/utils.py", line 23, in ask_for_it_by_name
ask_for_it_by_name.cache[name] = _ask_for_it_by_name(name)
File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/utils.py", line 17, in _ask_for_it_by_name
return getattr(module, bits[-1])
AttributeError: 'module' object has no attribute 'TVGuide'
Is there a way around?