Opened 17 years ago
Closed 17 years ago
#6040 closed (invalid)
post_syncdb signal and contrib.auth permissions
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Contrib apps | Version: | dev |
Severity: | Keywords: | auth contrib.auth post_syncdb management.py | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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?
Questions about how best to use Django should be directed to the django-users mailing list.