0

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.
nu everest
  • 9,589
  • 12
  • 71
  • 90

2 Answers2

2

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.

Brandon Gao
  • 623
  • 5
  • 9
  • auth_group_permissions does not exist in the database. How do I manually create it? – nu everest Jan 31 '13 at 22:16
  • The issue turned out to be a database problem. Somehow auth_group_permissions got dropped... So I created a new database. I created a new django project. Ran syncdb. Then I ran the following commands under MYSQL as root USE ; CREATE TABLE auth_group_permissions LIKE .auth_group_permissions; – nu everest Jan 31 '13 at 23:47
1

The model field of the contenttype of the auth.message is 'message' instead of 'messages'.
so try

ct = ContentType.objects.get(app_label='auth',model='message')

You could then list ct.permission_set.all() or even run ct.delete() (in transaction and print relative objects to be deleted) to reproduce the issue.

Also, the error about 'missing table' is weird, can you check in DB whether the table really exists? Or do you have multiple DBs configured in 1.3?

okm
  • 23,575
  • 5
  • 83
  • 90
  • Good catch on my typo. However, when I run ct.delete() I'm still getting DatabaseError: (1146, "Table '.auth_group_permissions' doesn't exist"). It turns out that this table does not exist when I took a look at my database, but I'm not sure how to create it. – nu everest Jan 31 '13 at 22:18
  • When I run ct.permission_set.all() I get: [, , ] – nu everest Jan 31 '13 at 22:21
  • I only have one database. However, I have two separate projects that share the database. The projects do not share the same tables. – nu everest Jan 31 '13 at 22:30
  • @nueverest it's fine you've solved it. Remember to backup important data when you need to manually operate DB. On localhost, you could safely remove and rebuild tables or whole DB. – okm Feb 02 '13 at 11:07