| 1 | = How to run {{{manage.py syncdb}}} without being prompted to create a superuser = |
| 2 | |
| 3 | '''This applies only to post-magic-removal versions of Django.''' |
| 4 | |
| 5 | In my project I found it annoying being prompted to create a superuser everytime I ran {{{manage.py syncdb}}} or from my custom installation script {{{management.syncdb()}}}. Delving a little deeper I found that I could disable this by "disconnecting" {{{django.contrib.auth.mangement.create_superuser}}} from the new event dispatcher in Django. |
| 6 | |
| 7 | The following snippet does just that. |
| 8 | |
| 9 | {{{ |
| 10 | #!python |
| 11 | from django.core import management |
| 12 | from django.dispatch import dispatcher |
| 13 | from django.contrib.auth.management import create_superuser |
| 14 | from django.contrib.auth import models as auth_app |
| 15 | from django.db.models import signals |
| 16 | |
| 17 | dispatcher.disconnect(create_superuser, sender=auth_app, signal=signals.post_syncdb) |
| 18 | management.syncdb() |
| 19 | }}} |
| 20 | |
| 21 | Now if I could only make {{{management.syncdb()}}} less verbose. |