﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33385	Unexpected behavior regarding custom permissions creation	Ramez Issac	nobody	"Hello wonderful Django community ,

Brief of the issue: 
Custom permissions are created at the very end of a manage.py migrate.
Not after its addition in the same migration `migrations.AlterModelOptions`, Nor after the its specific migration is applied .

Outcome:
One can not assign custom permissions in a data migration.

Use Case:
I added some custom permissions on a model and i want to assign some of those new permissions to users based on some criteria.
I made this assignment in the same migration. It failed because the new permissions were not found.
Ok, i can understand that...
So, i made another data migration and put the assignment there,  also this fails because permission is not found.

What i have to do then is 
1. python manage.py migrate my_app migration_with_meta_change_adding_perms
Then 
2. python manage.py migrate my_app migration_with_the_run_python_assign_permissions

And i have to execute it explicitly like shown above or else it will fail... i don't think this is the expected behavior.

"	Uncategorized	closed	contrib.auth	2.2	Normal	duplicate			Unreviewed	0	0	0	0	0	0
