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
This commit is contained in:
Joseph Kocherhans 2006-01-09 18:23:30 +00:00
parent 6cdb3c57d8
commit e65f226623
1 changed files with 12 additions and 7 deletions

View File

@ -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)