It seems Django is creating new Permission records in a post_migrate
signal handler, especially in the method create_permissions which is
called
[https://github.com/django/django/blob/263ee4434fe814ee15ef231549273f16d7fad520/django/contrib/auth/apps.py#L20
here].
It would be great if it was possible to act on Permission creation. I mean
by using create() instead of bulk_create(), pre_save() and post_save()
signals would be sent and therefore it would be possible to, for instance,
assign a Permission once it is created with the post_save() signal.
I guess the only think to do would be to change
[https://github.com/django/django/blob/263ee4434fe814ee15ef231549273f16d7fad520/django/contrib/auth/management/__init__.py#L83
this line].
I could even do it if you say it will be accepted.
Otherwise how could it be possible to achieve it ? I mean assign a
Permission once it is created..?
Kind regards,
A Django Lover.
--
Ticket URL: <https://code.djangoproject.com/ticket/32695>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => BRISBOIS Laurent
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:1>
Comment (by BRISBOIS Laurent):
Added a PR to solve this : https://github.com/django/django/pull/14326
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:2>
Comment (by Tim Graham):
Permission creation was changed from `create()` to `bulk_create()` in
7deb25b8dd5aa1ed02b5e30cbc67cd1fb0c3d6e6 (#7596).
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:3>
Comment (by BRISBOIS Laurent):
I see that it seems to be only a performance reason that was behind this
original change.
But what if people need to react on this (in my opinion) important step
which is the creation of the Permissions ?
I think it should be considered again to put `create()` back here
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:4>
* has_patch: 0 => 1
* stage: Unreviewed => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:5>
* stage: Ready for checkin => Unreviewed
Comment:
Please don't mark your own ticket and patch as ready for checkin. The
ticket should be triaged and the patch reviewed by another person.
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:6>
Comment (by BRISBOIS Laurent):
@Tim Graham Huh sorry I read
[https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
/submitting-patches/#patch-review-checklist this] and I may have made a
mistake. My apologies. I didn't intend to force it at all.
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:7>
* status: assigned => closed
* resolution: => wontfix
Comment:
> But what if people need to react on this (in my opinion) important step
which is the creation of the Permissions?
I think it's really niche because no one has reported this in the last 10
years. You should be able to add e.g. a `post_migrate` handler or a
scheduler job and check for new permissions. You can also try to ask for
alternatives on one of
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels]. I don't think this is worth changing at the moment.
Moreover, as far as I'm aware your issue will be fixed by #29843, which
propose including permissions in migrations files.
--
Ticket URL: <https://code.djangoproject.com/ticket/32695#comment:8>