Changes between Initial Version and Version 1 of CookBookScriptsNoSuperUserSyncdb


Ignore:
Timestamp:
May 4, 2006, 7:23:30 PM (19 years ago)
Author:
mattimustang@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBookScriptsNoSuperUserSyncdb

    v1 v1  
     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
     5In 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
     7The following snippet does just that.
     8
     9{{{
     10#!python
     11from django.core import management
     12from django.dispatch import dispatcher
     13from django.contrib.auth.management import create_superuser
     14from django.contrib.auth import models as auth_app
     15from django.db.models import signals
     16
     17dispatcher.disconnect(create_superuser, sender=auth_app, signal=signals.post_syncdb)
     18management.syncdb()
     19}}}
     20
     21Now if I could only make {{{management.syncdb()}}} less verbose.
Back to Top