You can do this yourself:
- Create a management command to prompt for your new site
- connect it to the
post_syncdb
signal
The command will let you set the site conveniently from the command line. Connecting it to the signal will mean you get prompted whenever the sites
app is installed. eg:
from django.contrib.sites import models as sites_app
signals.post_syncdb.connect(create_site, sender=sites_app)
When writing the create_site
function (signal handler), you can copy the auth
module's approach almost exactly:
def create_site(app, created_models, verbosity, **kwargs):
from django.contrib.sites.models import Site
from django.core.management import call_command
if Site in created_models and kwargs.get('interactive', True):
msg = "\nYou just installed Django's sites system, which means you don't have " \
"any sites defined.\nWould you like to create one now? (yes/no): "
confirm = raw_input(msg)
while 1:
if confirm not in ('yes', 'no'):
confirm = raw_input('Please enter either "yes" or "no": ')
continue
if confirm == 'yes':
call_command("createsite", interactive=True)
break
Now you just need to create your management command createsite
and you're done. I do wonder why this isn't already in Django though, I hate example.com.
Put all this into a little app and reuse it for every project your do. Bonus points if you post the app somewhere like google code or django's bug tracker.