Sunday, January 13, 2019

migrate failed due to Permission

Hello.

I want to migrate all tables into new database but bumped into an error that it said "auth_permission" is not found.
Then I searched for the possible causes, it turned out that it is because I accessed the auth model "Permission" in my code before the migrate creating table in database.
I tried to run python manage.py migrate auth, but nothing changed.

So maybe I have to change my code ... I have to filter out managers by its permission.

manager_permission
= Permission.objects.get(codename='manager')
managers = User.objects.filter(project=project).filter(user_permissions=manager_permission)

User.user_permissions is only allowed to use the permission code which could be different every time I re-migrate the whole database.

So I am asking if there is a better way to filter out managers by its perm or other solutions ? :)

Thank you in advance.





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1fa0e7fb-30fc-487f-8fae-1e23183476a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment