I have run a few fake migrations yesterday and also renamed a few tables of my database direcly yesterday due to foreign key constraints and other similar errors Django kept throwing at me after renaming some models.
I know this is not standard procedure and it's prone to messing up things. It did solve everything for me though, without the need of wiping out the database, as I was almost resolved to do.
Anyway, as I said, all is working great, expect for the list shown in the 'available permissions' in the Group management. The following (and other) tables are not in the database, and indeed are not even prepended with the applications's name:
Where are those sourced from? How can I get rid of them?
CodePudding user response:
You can use django shell to get ride of old permissions like this :
from django.contrib.auth.models import Permission
# Assume that you have all name of the old permissions to delete in a list
permission_old = ['permission_name_1', 'permission_name_2', ...]
for perm in Permission.objects.all():
if str(perm) in permission_old:
print(perm)
perm.delete()
Or read this post
CodePudding user response:
Thanks to @Rvector's answer I was pointed to this post where this answer made me aware of the remove_stale_contenttypes command which
[d]eletes stale content types (from deleted models) in your database. Any objects that depend on the deleted content types will also be deleted.