On 6/09/2017 3:43 PM, Brian May wrote:

Hello,

Just wondering how to create groups automatically in Django and automatically assign permissions?

Sounds easy. I have created a database migration to do just this.

The problem is under Django the permissions are not created until after all the migrations are finished. So the resultant migration works fine on my development box, but fails badly on new installs, including tests.


Can you separate the process into separate migrations? Each can have a dependency on the one prior.

Looking at slashdot, I see questions like https://stackoverflow.com/questions/42743825/how-to-create-groups-and-assign-permission-during-project-setup-in-django which recommend setting up a post_migrate signal handler. Unfortunately, signal handlers in Django are unordered, there is no guarantee our handler will be called after the one that creates the permissions.

I could also have some sort of button in Django Admin that needs to be manually pressed - would happen after permissions are created. Seems to me though that doing significant changes to the database group table from a HTTP request may not be ideal...

Any other suggestions? I am somewhat surprised that this situation doesn't seem to have any good answers.

Regards



_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug

_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to