magic-removal: Changed get_object_or_404 to take the model class, not the magic model module

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1666 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-12-15 01:00:22 +00:00
parent eaeb1acebc
commit a56ba15f73
2 changed files with 6 additions and 6 deletions

View File

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

View File

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