diff --git a/django/contrib/flatpages/views.py b/django/contrib/flatpages/views.py index 48cd4526ab..18595e6a35 100644 --- a/django/contrib/flatpages/views.py +++ b/django/contrib/flatpages/views.py @@ -1,6 +1,6 @@ +from django.contrib.flatpages.models import FlatPage from django.core import template_loader from django.core.extensions import get_object_or_404, DjangoContext -from django.models.flatpages import flatpages from django.utils.httpwrappers import HttpResponse from django.conf.settings import SITE_ID @@ -19,7 +19,7 @@ def flatpage(request, url): """ if not url.startswith('/'): url = "/" + url - f = get_object_or_404(flatpages, url__exact=url, sites__id__exact=SITE_ID) + f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=SITE_ID) # If registration is required for accessing this page, and the user isn't # logged in, redirect to the login page. if f.registration_required and request.user.is_anonymous(): diff --git a/django/core/extensions.py b/django/core/extensions.py index 52b24061ff..1b925ba4f4 100644 --- a/django/core/extensions.py +++ b/django/core/extensions.py @@ -2,7 +2,7 @@ # of MVC. In other words, these functions/classes introduce controlled coupling # for convenience's sake. -from django.core.exceptions import Http404, ObjectDoesNotExist +from django.core.exceptions import Http404 from django.core.template import Context, loader from django.conf.settings import DEBUG, INTERNAL_IPS from django.utils.httpwrappers import HttpResponse @@ -11,10 +11,10 @@ def render_to_response(*args, **kwargs): return HttpResponse(loader.render_to_string(*args, **kwargs)) load_and_render = render_to_response # For backwards compatibility. -def get_object_or_404(mod, **kwargs): +def get_object_or_404(klass, **kwargs): try: - return mod.get_object(**kwargs) - except ObjectDoesNotExist: + return klass._default_manager.get_object(**kwargs) + except klass.DoesNotExist: raise Http404 def get_list_or_404(mod, **kwargs):