Search code examples
pythondjangocontent-typesyncdb

After Upgrading Django from 1.3 to 1.4.3 Syncdb Fails to delete stale content types


How can I successfully delete the stale content?
Typing yes yields the following:

Creating tables ...

The following content types are stale and need to be deleted:

auth | message

Any objects related to these content types by a foreign key will also be deleted. Are you sure you want to delete these content types? If you're unsure, answer 'no'.

Type 'yes' to continue, or 'no' to cancel: yes

Traceback (most recent call last): ...

raise errorclass, errorvalue
django.db.utils.DatabaseError: 
(1146, "Table '<db_name>.auth_group_permissions' doesn't exist")
Process finished with exit code 1

The other thing I tried was:

from django.contrib.contenttypes.models import ContentType
ct = ContentType.objects.get(app_label='auth',model='messages')

And I receive the following:

DoesNotExist: ContentType matching query does not exist.

Solution

  • You can do a

    python manage.py dbshell
    

    and check all the tables created by you before.

    See if auth_group_permissions exists. If it's not there, I guess you can manually create it and do the process again.