Question

I have created a permission system in django. It is inside an App called HelperApp. First it inputs permissions definition into the database with post_syncdb signals(sender is the models of HelperApp, which does not contain any model classes), and then listens to the post_save of User in django.contrib.auth, and add default permissions to them.

Now the problem is, when there was no database file yet and I call manage.py syncdb, the Auth App will create some default users right after the User table is created (Superuser and AnonymousUser). The permission system tries to give them default permissions, but the permissions are not created yet.

Currently, only if I put 'HelperApp' before 'django.contrib.auth' in settings.py INSTALLED_APPS will it work. The question is, is there a way to define the sequence of table creation without the need of juggling names in INSTALLED_APPS?

Was it helpful?

Solution

Just use fixtures to create your inital data: https://docs.djangoproject.com/en/dev/howto/initial-data/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top