post_syncdb signal and contrib.auth permissions
|Reported by:||Dan <danielnaab@…>||Owned by:||nobody|
|Severity:||Keywords:||auth contrib.auth post_syncdb management.py|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
This is a feature request for contrib.auth's management.py
In an app's management.py, doing:
from myapp import models from django.contrib.auth.models import Permission def init_data(): perm = Permission.objects.get(codename=<permission string for models.my_model>) dispatcher.connect(init_data, sender=models, signal=signals.post_syncdb)
where <permission string for models.my_model> is something like "change_mymodel", will trigger a DoesNotExist exception on first run of syncdb.
The problem is that contrib.auth is receiving the post_syncdb signal before "myapp", and there doesn't appear to be a way to force myapp to be the last receiver of the signal. Changing the order of the apps in settings.py has no effect.
A suggested solution would be to add a new signal fired by contrib.auth after creation of permissions. Or am I missing an obvious way to handle after contrib.auth?