Version 1 (modified by mattimustang@…, 12 years ago) (diff)


How to run syncdb without being prompted to create a superuser

This applies only to post-magic-removal versions of Django.

In my project I found it annoying being prompted to create a superuser everytime I ran 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.

The following snippet does just that.

from django.core import management
from django.dispatch import dispatcher
from import create_superuser
from django.contrib.auth import models as auth_app
from django.db.models import signals

dispatcher.disconnect(create_superuser, sender=auth_app, signal=signals.post_syncdb)

Now if I could only make management.syncdb() less verbose.

Back to Top