Django permissions: new permission is inserted after all other migrations

I added a new permission for my model and used manage.py makemigrations . he created a migration that changes the model parameters (in particular, permissions ...).

later, I added a migration that is dependent on the first migration, and uses permission (which I thought created the first migration). that the migration used permission in a RunSQL operation that requested auth_permissions.

how I debugged migrations - I realized that the insertion into the auth permission occurs only after all the migrations have been applied.

Meaning - when I try to request a permission identifier to use it in the second migration - it does not exist, and therefore the second migration does not behave as expected.

any idea why this is happening and how to prevent it? my guess when adding the new permission was that it would be added with the migration created by django for me .. and not at another stage.

Thank!

+4
source share

Source: https://habr.com/ru/post/1672202/


All Articles