From e65f2266239bc63d313a81522e82fe66ea15aeda Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Mon, 9 Jan 2006 18:23:30 +0000 Subject: [PATCH] magic-removal: updated django-admin.py init and init-minimal to install django.contrib.contenttypes. init-minimal does so because it is run before the tests, and the tests require django.contrib.contenttypes to be installed. This should be revisited. See the comments in django.core.management.init_minimal for details. git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1888 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/django/core/management.py b/django/core/management.py index fbb0337550..fb8b7d2f24 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -457,10 +457,15 @@ def init_minimal(): "Initializes the database." try: from django.db import backend, connection, models - from django.models import core cursor = connection.cursor() - for sql in get_sql_create(core) + get_sql_initial_data(core): - cursor.execute(sql) + # This should probably be done in the test runner, or the test itself. + from django.conf.settings import INSTALLED_APPS + INSTALLED_APPS += ('django.contrib.contenttypes',) + # Install django.contrib.contenttypes. The tests require Packages to + # to be installed. This ought to be fixed (tests should probably + # install their dependencies) + contenttypes_app = models.get_app('contenttypes') + install(contenttypes_app) except Exception, e: import traceback @@ -479,11 +484,11 @@ def init(): "Initializes the database with auth, sessions, sites and core." try: from django.db import backend, connection, models - from django.models import core from django.contrib.sites.models import Site cursor = connection.cursor() - for sql in get_sql_create(core) + get_sql_initial_data(core): - cursor.execute(sql) + # Install django.contrib.contenttypes. + contenttypes_app = models.get_app('contenttypes') + install(contenttypes_app) # Install django.contrib.auth. auth_app = models.get_app('auth') install(auth_app) @@ -548,7 +553,7 @@ install.args = APP_ARGS def installperms(app): "Installs any permissions for the given app, if needed." from django.contrib.auth.models import Permission - from django.models.core import Package + from django.contrib.contenttypes.models import Package from django.db.models import get_models num_added = 0 app_models = get_models(app)