From 33451f2172674f01c618bfc4e0bd409909f43b35 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Fri, 6 Jan 2006 22:29:01 +0000 Subject: [PATCH] magic-removal: Removed Sites from django.models.core and updated dependencies. git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1844 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/views/doc.py | 2 +- django/contrib/comments/feeds.py | 2 +- django/contrib/syndication/feeds.py | 2 +- django/core/management.py | 14 +++++++++++--- django/models/core.py | 22 ---------------------- django/views/defaults.py | 3 ++- 6 files changed, 16 insertions(+), 29 deletions(-) diff --git a/django/contrib/admin/views/doc.py b/django/contrib/admin/views/doc.py index ee52078187..d14e998b9a 100644 --- a/django/contrib/admin/views/doc.py +++ b/django/contrib/admin/views/doc.py @@ -6,7 +6,7 @@ from django.core.extensions import DjangoContext, render_to_response from django.core.exceptions import Http404, ViewDoesNotExist from django.core import template, urlresolvers from django.contrib.admin import utils -from django.models.core import Site +from django.contrib.sites.models import Site import inspect, os, re # Exclude methods starting with these strings from documentation diff --git a/django/contrib/comments/feeds.py b/django/contrib/comments/feeds.py index e402d02cc6..d985018206 100644 --- a/django/contrib/comments/feeds.py +++ b/django/contrib/comments/feeds.py @@ -2,7 +2,7 @@ from django.conf import settings from django.contrib.comments.models import Comment, FreeComment from django.contrib.syndication.feeds import Feed from django.core.exceptions import ObjectDoesNotExist -from django.models.core import Site +from django.contrib.sites.models import Site class LatestFreeCommentsFeed(Feed): """Feed of latest comments on the current site""" diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py index 2a08cae109..902cde7003 100644 --- a/django/contrib/syndication/feeds.py +++ b/django/contrib/syndication/feeds.py @@ -1,6 +1,6 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist from django.core.template import Context, loader, Template, TemplateDoesNotExist -from django.models.core import Site +from django.contrib.sites.models import Site from django.utils import feedgenerator from django.conf.settings import LANGUAGE_CODE, SETTINGS_MODULE diff --git a/django/core/management.py b/django/core/management.py index cc39711964..3d220d857f 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -458,12 +458,20 @@ def init(): try: from django.db import backend, connection, models from django.models import auth, core + from django.contrib.sites.models import Site cursor = connection.cursor() for sql in get_sql_create(core) + get_sql_create(auth) + get_sql_initial_data(core) + get_sql_initial_data(auth): cursor.execute(sql) - cursor.execute("INSERT INTO %s (%s, %s) VALUES ('example.com', 'Example site')" % \ - (backend.quote_name(core.Site._meta.db_table), backend.quote_name('domain'), - backend.quote_name('name'))) + # XXX: commented out for now because it breaks the model tests. Will + # fix when the command init-minimal is added. + + # Install django.contrib.sites and create an example site. + #sites_app = models.get_app('sites') + #install(sites_app) + #cursor.execute("INSERT INTO %s (%s, %s) VALUES ('example.com', 'Example site')" % \ + # (backend.quote_name(Site._meta.db_table), backend.quote_name('domain'), + # backend.quote_name('name'))) + except Exception, e: import traceback sys.stderr.write("Error: The database couldn't be initialized.\n") diff --git a/django/models/core.py b/django/models/core.py index 472be356d3..44048aa7ae 100644 --- a/django/models/core.py +++ b/django/models/core.py @@ -3,28 +3,6 @@ import cPickle as pickle from django.db import models from django.utils.translation import gettext_lazy as _ -class SiteManager(models.Manager): - def get_current(self): - from django.conf.settings import SITE_ID - return self.get_object(pk=SITE_ID) - -class Site(models.Model): - domain = models.CharField(_('domain name'), maxlength=100) - name = models.CharField(_('display name'), maxlength=50) - objects = SiteManager() - class Meta: - verbose_name = _('site') - verbose_name_plural = _('sites') - db_table = 'sites' - ordering = ('domain',) - admin = models.Admin( - list_display = ('domain', 'name'), - search_fields = ('domain', 'name'), - ) - - def __repr__(self): - return self.domain - class Package(models.Model): label = models.CharField(_('label'), maxlength=20, primary_key=True) name = models.CharField(_('name'), maxlength=30, unique=True) diff --git a/django/views/defaults.py b/django/views/defaults.py index 0823d42347..c6721ab3ef 100644 --- a/django/views/defaults.py +++ b/django/views/defaults.py @@ -1,6 +1,7 @@ from django.core.exceptions import Http404, ObjectDoesNotExist from django.core.template import Context, loader -from django.models.core import ContentType, Site +from django.models.core import ContentType +from django.contrib.sites.models import Site from django.utils import httpwrappers def shortcut(request, content_type_id, object_id):