mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
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
This commit is contained in:
parent
c4076a4314
commit
33451f2172
@ -6,7 +6,7 @@ from django.core.extensions import DjangoContext, render_to_response
|
|||||||
from django.core.exceptions import Http404, ViewDoesNotExist
|
from django.core.exceptions import Http404, ViewDoesNotExist
|
||||||
from django.core import template, urlresolvers
|
from django.core import template, urlresolvers
|
||||||
from django.contrib.admin import utils
|
from django.contrib.admin import utils
|
||||||
from django.models.core import Site
|
from django.contrib.sites.models import Site
|
||||||
import inspect, os, re
|
import inspect, os, re
|
||||||
|
|
||||||
# Exclude methods starting with these strings from documentation
|
# Exclude methods starting with these strings from documentation
|
||||||
|
@ -2,7 +2,7 @@ from django.conf import settings
|
|||||||
from django.contrib.comments.models import Comment, FreeComment
|
from django.contrib.comments.models import Comment, FreeComment
|
||||||
from django.contrib.syndication.feeds import Feed
|
from django.contrib.syndication.feeds import Feed
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.models.core import Site
|
from django.contrib.sites.models import Site
|
||||||
|
|
||||||
class LatestFreeCommentsFeed(Feed):
|
class LatestFreeCommentsFeed(Feed):
|
||||||
"""Feed of latest comments on the current site"""
|
"""Feed of latest comments on the current site"""
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
|
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
|
||||||
from django.core.template import Context, loader, Template, TemplateDoesNotExist
|
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.utils import feedgenerator
|
||||||
from django.conf.settings import LANGUAGE_CODE, SETTINGS_MODULE
|
from django.conf.settings import LANGUAGE_CODE, SETTINGS_MODULE
|
||||||
|
|
||||||
|
@ -458,12 +458,20 @@ def init():
|
|||||||
try:
|
try:
|
||||||
from django.db import backend, connection, models
|
from django.db import backend, connection, models
|
||||||
from django.models import auth, core
|
from django.models import auth, core
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
for sql in get_sql_create(core) + get_sql_create(auth) + get_sql_initial_data(core) + get_sql_initial_data(auth):
|
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(sql)
|
||||||
cursor.execute("INSERT INTO %s (%s, %s) VALUES ('example.com', 'Example site')" % \
|
# XXX: commented out for now because it breaks the model tests. Will
|
||||||
(backend.quote_name(core.Site._meta.db_table), backend.quote_name('domain'),
|
# fix when the command init-minimal is added.
|
||||||
backend.quote_name('name')))
|
|
||||||
|
# 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:
|
except Exception, e:
|
||||||
import traceback
|
import traceback
|
||||||
sys.stderr.write("Error: The database couldn't be initialized.\n")
|
sys.stderr.write("Error: The database couldn't be initialized.\n")
|
||||||
|
@ -3,28 +3,6 @@ import cPickle as pickle
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
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):
|
class Package(models.Model):
|
||||||
label = models.CharField(_('label'), maxlength=20, primary_key=True)
|
label = models.CharField(_('label'), maxlength=20, primary_key=True)
|
||||||
name = models.CharField(_('name'), maxlength=30, unique=True)
|
name = models.CharField(_('name'), maxlength=30, unique=True)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from django.core.exceptions import Http404, ObjectDoesNotExist
|
from django.core.exceptions import Http404, ObjectDoesNotExist
|
||||||
from django.core.template import Context, loader
|
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
|
from django.utils import httpwrappers
|
||||||
|
|
||||||
def shortcut(request, content_type_id, object_id):
|
def shortcut(request, content_type_id, object_id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user