From 3cf23a5c36bdf59c9510ef8a30399473bfd69d40 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 3 Mar 2006 23:13:38 +0000 Subject: [PATCH] magic-removal: django-admin syncdb now installs example site object (and doesn't fail on install perms anymore) git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2483 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/django/core/management.py b/django/core/management.py index cd6acd138f..c70a3f2612 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -368,7 +368,6 @@ def get_sql_all(app): get_sql_all.help_doc = "Prints the CREATE TABLE and initial-data SQL statements for the given model module name(s)." get_sql_all.args = APP_ARGS -# TODO: Put "example.com" site in initial SQL data for sites app def syncdb(): "Creates the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." from django.db import connection, transaction, models, get_creation_module, get_introspection_module @@ -420,7 +419,8 @@ def syncdb(): transaction.commit_unless_managed() - # Install permissions (first checking that they're installed) + # Install permissions and initial data (first checking that they're installed) + for app in models.get_apps(): if install_permissions: try: installperms(app) @@ -437,7 +437,7 @@ def syncdb(): # Install initial data for the app (but only if this is a model we've # just created) - for model in model_list: + for model in models.get_models(app): if model in created_models: initial_sql = get_sql_initial_data_for_model(model) if initial_sql: @@ -452,6 +452,13 @@ def syncdb(): else: transaction.commit_unless_managed() + # Create an initial "example.com" site (if we need to) + from django.contrib.sites.models import Site + if Site in created_models: + print "Creating example site object" + ex = Site(domain="example.com", name="example.com") + ex.save() + syncdb.args = '' def get_admin_index(app):